ALICE 1.3  1.0
Developer documentation
alice-desktop-1.3.pyw
Go to the documentation of this file.
1 #!/usr/bin/python
2 # -*- coding: cp1252 -*-
3 #
4 # ADALM1000 alice-desktop 1.3.py(w) (4-29-2022)
5 # For Python version 2.7 or 3.7, Windows OS and Linux OS
6 # With external module pysmu ( libsmu >= 1.0.2 for ADALM1000 )
7 # optional split I/O modes for Rev F hardware supported
8 # Uses new firmware (2.17 or >) that support control of ADC mux configure
9 # Created by D Mercer ()
10 #
11 #
12 import __future__
13 import math
14 import time
15 try:
16  import numpy
17  numpy_found = True
18 except:
19  numpy_found = False
20 #
21 # If runing from source you can un-comment the following to include pyplot
22 try:
23  from matplotlib import pyplot as plt
24  matplot_found = True
25 except:
26  matplot_found = False
27 #
28 import csv
29 import wave
30 import os
31 #import requests
32 import sys
33 import struct
34 import subprocess
35 from time import gmtime, strftime
36 # Check to see if user passed init file name on command line
37 if len(sys.argv) > 1:
38  InitFileName = str(sys.argv[1])
39  print( 'Init file name: ' + InitFileName )
40 else:
41  InitFileName = 'alice_init.ini'
42 
43 if sys.version_info[0] == 2:
44  print ("Python 2.x")
45  import urllib2
46  import tkFont
47  from Tkinter import *
48  from ttk import *
49  from tkFileDialog import askopenfilename
50  from tkFileDialog import asksaveasfilename
51  from tkSimpleDialog import askstring
52  from tkMessageBox import *
53  from tkColorChooser import askcolor
54 if sys.version_info[0] == 3:
55  print ("Python 3.x")
56  import urllib.request, urllib.error, urllib.parse
57  from tkinter.font import *
58  from tkinter import *
59  from tkinter.ttk import *
60  from tkinter.filedialog import askopenfilename
61  from tkinter.filedialog import asksaveasfilename
62  from tkinter.simpledialog import askstring
63  from tkinter.messagebox import *
64  from tkinter.colorchooser import askcolor
65 #
66 import webbrowser
67 try:
68  from pysmu import *
69  pysmu_found = True
70 except:
71  pysmu_found = False
72 #
73 # check which operating system
74 import platform
75 #
76 RevDate = "29 April 2022"
77 SWRev = "1.3.13 "
78 Version_url = 'https://github.com/analogdevicesinc/alice/releases/download/1.3.13/alice-desktop-1.3-setup.exe'
79 # small bit map of ADI logo for window icon
80 TBicon = """
81 R0lGODlhIAAgAHAAACH5BAEAAAIALAAAAAAgACAAgQAAAP///wAAAAAAAAJJhI+py+0PYwtBWkDp
82 hTnv2XlfEobjUZZnmn4se72vJMtcbYN4ruz44uORgiodsfI4Im++2M5VW81OmBbVULxiRVrUsgsO
83 i8fUAgA7
84 """
85 
86 root=Tk()
87 root.title("ALICE DeskTop " + SWRev + RevDate + ": ALM1000 Oscilloscope")
88 img = PhotoImage(data=TBicon)
89 root.call('wm', 'iconphoto', root._w, '-default', img)
90 print("Windowing System is " + str(root.tk.call('tk', 'windowingsystem')))
91 
92 GRW = 720 # Width of the time grid 720 default
93 GRH = 390 # Height of the time grid 390 default
94 X0L = 55 # Left top X value of time grid
95 Y0T = 25 # Left top Y value of time grid
96 #
97 GRWF = 720 # Width of the spectrum grid 720 default
98 GRHF = 390 # Height of the spectrum grid 390 default
99 X0LF = 45 # Left top X value of spectrum grid
100 Y0TF = 25 # Left top Y value of spectrum grid
101 #
102 GRWBP = 720 # Width of the Bode Plot grid 720 default
103 GRHBP = 390 # Height of the Bode Plot grid 390 default
104 X0LBP = 45 # Left top X value of Bode Plot grid
105 Y0TBP = 25 # Left top Y value of Bode Plot grid
106 #
107 GRWXY = 420 # Width of the XY grid 420 default
108 GRHXY = 390 # Height of the XY grid 390 default
109 X0LXY = 55 # Left top X value of XY grid
110 Y0TXY = 25 # Left top Y value of XY grid
111 #
112 GRWIA = 400 # Width of the grid 400 default
113 GRHIA = 400 # Height of the grid 400 default
114 X0LIA = 37 # Left top X value of grid
115 Y0TIA = 25 # Left top Y value of grid
116 #
117 GRWNqP = 400 # Width of the Nyquist plot grid 400 default
118 GRHNqP = 400 # Height of the grid 400 default
119 X0LNqP = 25 # Left top X value of grid
120 Y0TNqP = 25 # Left top Y value of grid
121 #
122 GRWNiC = 400 # Width of the Nichols plot grid 400 default
123 GRHNiC = 400 # Height of the grid 400 default
124 X0LNiC = 25 # Left top X value of grid
125 Y0TNiC = 25 # Left top Y value of grid
126 #
127 GRWPhA = 400 # Width of the grid 400 default
128 GRHPhA = 400 # Height of the grid 400 default
129 X0LPhA = 37 # Left top X value of grid
130 Y0TPhA = 25 # Left top Y value of grid
131 #
132 FontSize = 8
133 BorderSize = 1
134 MouseX = MouseY = -10
135 MouseCAV = MouseCAI = MouseCBV = MouseCBI = MouseMuxA = MouseMuxB = MouseMuxC = MouseMuxD = -10
136 
138  global COLORtext, COLORcanvas, COLORtrigger, COLORsignalband, COLORframes, COLORgrid, COLORzeroline
139  global COLORtrace1, COLORtraceR1, COLORtrace2, COLORtraceR2, COLORtrace3, COLORtraceR3, COLORtrace4, COLORtraceR4
140  global COLORtrace5, COLORtraceR5, COLORtrace6, COLORtraceR6, COLORtrace7, COLORtraceR7
141 
142  COLORtext = "#ffffff" # 100% white
143  COLORtrigger = "#ff0000" # 100% red
144  COLORsignalband = "#ff0000" # 100% red
145  COLORframes = "#000080" # Color = "#rrggbb" rr=red gg=green bb=blue, Hexadecimal values 00 - ff
146  COLORcanvas = "#000000" # 100% black
147  COLORgrid = "#808080" # 50% Gray
148  COLORzeroline = "#0000ff" # 100% blue
149  COLORtrace1 = "#00ff00" # 100% green
150  COLORtrace2 = "#ff8000" # 100% orange
151  COLORtrace3 = "#00ffff" # 100% cyan
152  COLORtrace4 = "#ffff00" # 100% yellow
153  COLORtrace5 = "#ff00ff" # 100% magenta
154  COLORtrace6 = "#C80000" # 90% red
155  COLORtrace7 = "#8080ff" # 100% purple
156  COLORtraceR1 = "#008000" # 50% green
157  COLORtraceR2 = "#905000" # 50% orange
158  COLORtraceR3 = "#008080" # 50% cyan
159  COLORtraceR4 = "#808000" # 50% yellow
160  COLORtraceR5 = "#800080" # 50% magenta
161  COLORtraceR6 = "#800000" # 80% red
162  COLORtraceR7 = "#4040a0" # 80% purple
163 
164 #
165 ResetColors()
166 ButtonGreen = "#00ff00" # 100% green
167 ButtonRed = "#ff0000" # 100% red
168 GUITheme = "Light"
169 ButtonOrder = 0
170 SBoxarrow = 11
171 Closed = 0
172 ColorMode = IntVar(0)
173 # # Can be Light or Dark or Blue or LtBlue or Custom where:
174 FrameBG = "#d7d7d7" # Background color for frame
175 ButtonText = "#000000" # Button Text color
176 # Widget relief can be RAISED, GROOVE, RIDGE, and FLAT
177 ButRelief = RAISED
178 LabRelief = FLAT
179 FrameRefief = RIDGE
180 LocalLanguage = "English"
181 
182 OnBoardRes = 50.83
183 AD584act = 2.5
184 # Set sample buffer size
185 HoldOff = 0.0
186 LShift = 0
187 BaseSampleRate = 100000
188 AWGSAMPLErate = BaseSampleRate # Sample rate of the AWG channels
189 SAMPLErate = BaseSampleRate # Scope sample rate can be decimated
190 MinSamples = 2000
191 MaxSamples = 200000
192 ETSrecord = 2000
193 AWGRecLength = 32768
194 DISsamples = GRW
195 First_Slow_sweep = 0
196 Slow_Sweep_Limit = 200
197 # set initial trigger conditions
198 TRIGGERlevel = 2.5 # Triggerlevel in volts
199 
200 MathString = "VBuffA[t] + VBuffB[t]"
201 MathUnits = " V"
202 MathXString = "VBuffA[t]"
203 MathXUnits = " V"
204 MathYString = "VBuffB[t]"
205 MathYUnits = " V"
206 UserAString = "MaxV1-VATop"
207 UserALabel = "OverShoot"
208 UserBString = "MinV2-VBBase"
209 UserBLabel = "UnderShoot"
210 MathAxis = "V-A"
211 MathXAxis = "V-A"
212 MathYAxis = "V-B"
213 AWGAMathString = "(VBuffA + VBuffB)/2"
214 AWGBMathString = "(VBuffA + VBuffB)/2"
215 AWGAcsvFile = "examplea.csv"
216 AWGBcsvFile = "exampleb.csv"
217 AWGAwavFile = "examplea.wav"
218 AWGBwavFile = "exampleb.wav"
219 FFTUserWindowString = "numpy.kaiser(SMPfft, 14) * 3"
220 DigFilterAString = "numpy.sinc(numpy.linspace(-1, 1, 91))"
221 DigFilterBString = "numpy.sinc(numpy.linspace(-1, 1, 91))"
222 AWGFilterAString = "numpy.sinc(numpy.linspace(-1, 1, 91))"
223 AWGFilterBString = "numpy.sinc(numpy.linspace(-1, 1, 91))"
224 ChaMeasString1 = "DCV1"
225 ChaMeasString2 = "DCI1"
226 ChaMeasString3 = "SV1"
227 ChaMeasString4 = "MaxV1-MinV1"
228 ChaMeasString5 = "MaxI1-MinI1"
229 ChaMeasString6 = "math.sqrt(SV1**2 - DCV1**2)"
230 ChbMeasString1 = "DCV2"
231 ChbMeasString2 = "DCI2"
232 ChbMeasString3 = "SV2"
233 ChbMeasString4 = "MaxV2-MinV2"
234 ChbMeasString5 = "MaxI2-MinI2"
235 ChbMeasString6 = "math.sqrt(SV2**2 - DCV2**2)"
236 ChaLableSrring1 = "CHA-DCV "
237 ChaLableSrring2 = "CHA-DCI "
238 ChaLableSrring3 = "CHA-TRMS "
239 ChaLableSrring4 = "CHA-VP-P "
240 ChaLableSrring5 = "CHA-IP-P "
241 ChaLableSrring6 = "CHA-ACRMS "
242 ChbLableSrring1 = "CHB-DCV "
243 ChbLableSrring2 = "CHB-DCI "
244 ChbLableSrring3 = "CHB-TRMS "
245 ChbLableSrring4 = "CHB-VP-P "
246 ChbLableSrring5 = "CHB-IP-P "
247 ChbLableSrring6 = "CHB-ACRMS "
248 LabelPlotText = IntVar(0)
249 PlotLabelText = "Custom Plot Label"
250 
251 GridWidth = IntVar(0)
252 GridWidth.set(1)
253 TRACEwidth = IntVar(0)
254 TRACEwidth.set(1)
255 TRACEaverage = IntVar(0) # Number of average sweeps for average mode
256 TRACEaverage.set(8)
257 Vdiv = IntVar(0)
258 Vdiv.set(10) # Number of vertical divisions for spectrum / Bode
259 LPFTrigger = IntVar(0) # trigger lpf on/off
260 Trigger_LPF_length = IntVar(0)
261 Trigger_LPF_length.set(10) # Length of Trigger box car LPF in samples
262 HarmonicMarkers = IntVar(0)
263 HarmonicMarkers.set(3)
264 AWGShowAdvanced = IntVar(0)
265 AWGShowAdvanced.set(0)
266 AWG_Amp_Mode = IntVar(0)
267 AWG_Amp_Mode.set(0) # 0 = Min/Max mode, 1 = Amp/Offset
268 AWGA_Ext_Gain = DoubleVar(0)
269 AWGA_Ext_Gain.set(1.0)
270 AWGA_Ext_Offset = DoubleVar(0)
271 AWGA_Ext_Offset.set(0.0)
272 AWGB_Ext_Gain = DoubleVar(0)
273 AWGB_Ext_Gain.set(1.0)
274 AWGB_Ext_Offset = DoubleVar(0)
275 AWGB_Ext_Offset.set(0.0)
276 LockFreq = IntVar(0) # Flag to lock AWG A and AWG B to same frequency
277 AWG_2X = IntVar(0) # selection variable to set AWG DAC channes for 2X samplerate modes
278 Two_X_Sample = IntVar(0) # selection variable to set ADC channes for 2X samplerate mode
279 Two_X_Sample.set(0)
280 ADC_Mux_Mode = IntVar(0) # selection variable to set ADC CHA for voltagr or current 2X samplerate mode
281 ADC_Mux_Mode.set(0)
282 Last_ADC_Mux_Mode = 0
283 Alternate_Sweep_Mode = IntVar(0) # alternate sweeps when in 2X samplerate mode
284 Alternate_Sweep_Mode.set(0)
285 #
286 ChopModeFilter = [0.25, 0.25, 0.25, 0.25] # [0.25, 0.25, 0.25, 0.25]
287 # ChopModeFilter = [0, 1, 2, 3, 4, 3, 2, 1, 0]
288 # ChopModeFilter = numpy.array(ChopModeFilter) / 16
289 Roll_Mode = IntVar(0) # select roll sweep (slow) mode
290 Roll_Mode.set(0)
291 #
292 UnAvgSav = IntVar(0) # Flag to save un trace averaged buffers
293 UnAvgSav.set(0)
294 ZEROstuffing = IntVar(0) # The zero stuffing value is 2 ** ZERO stuffing, calculated on initialize
295 ZEROstuffing.set(1)
296 FFTwindow = IntVar(0) # FFT window function variable
297 FFTwindow.set(5) # FFTwindow 0=None (rectangular B=1), 1=Cosine (B=1.24), 2=Triangular non-zero endpoints (B=1.33),
298  # 3=Hann (B=1.5), 4=Blackman (B=1.73), 5=Nuttall (B=2.02), 6=Flat top (B=3.77)
299 RelPhaseCorrection = 15 # Relative Phase error seems to be a random number each time board is powered up
300 RelPhaseCenter = IntVar(0)
301 RelPhaseCenter.set(0) # Center line value for phase plots
302 ImpedanceCenter = IntVar(0)
303 ImpedanceCenter.set(0) # Center line value for impedance plots
304 MultipleBoards = IntVar(0)
305 MultipleBoards.set(0) # Turn on access for multiple m1k boards
306 IgnoreFirmwareCheck = 0
307 EnableScopeOnly = 0
308 EnableXYPlotter = 1
309 EnablePhaseAnalizer = 1
310 EnableSpectrumAnalizer = 1
311 EnableBodePlotter = 1
312 EnableImpedanceAnalizer = 1
313 EnableOhmMeter = 1
314 EnableDigIO = 1
315 EnableCommandInterface = 0
316 EnableMuxMode = 0
317 EnablePIODACMode = 0
318 EnableMinigenMode = 0
319 EnablePmodDA1Mode = 0
320 EnableDigPotMode = 0
321 EnableGenericSerialMode = 0
322 EnableAD5626SerialMode = 0
323 EnableDigitalFilter = 0
324 EnableMeasureScreen = 0
325 EnableETSScreen = 0
326 EnableHSsampling = 0
327 EnableUserEntries = 0
328 AllowFlashFirmware = 0
329 DeBugMode = 0
330 ShowTraceControls = 0
331 # ADC Mux defaults
332 v1_adc_conf = 0x20F1
333 i1_adc_conf = 0x20F7
334 v2_adc_conf = 0x20F7
335 i2_adc_conf = 0x20F1
336 #
337 MouseFocus = 1
338 HistAsPercent = 0
339 ShowBallonHelp = 0
340 contloop = 0
341 discontloop = 0
342 AwgLayout = "Horz"
343 MarkerLoc = 'UL' # can be UL, UR, LL or LR
344 CHA_TC1 = DoubleVar(0)
345 CHA_TC1.set(1)
346 CHA_TC2 = DoubleVar(0)
347 CHA_TC2.set(1)
348 CHB_TC1 = DoubleVar(0)
349 CHB_TC1.set(1)
350 CHB_TC2 = DoubleVar(0)
351 CHB_TC2.set(1)
352 CHA_A1 = DoubleVar(0)
353 CHA_A1.set(1)
354 CHA_A2 = DoubleVar(0)
355 CHA_A2.set(1)
356 CHB_A1 = DoubleVar(0)
357 CHB_A1.set(1)
358 CHB_A2 = DoubleVar(0)
359 CHB_A2.set(1)
360 Auto_ETS_Comp = IntVar(0)
361 ETS_TC1 = DoubleVar(0)
362 ETS_TC1.set(0.18333)
363 ETS_A1 = DoubleVar(0)
364 ETS_A1.set(5.0)
365 ETS_TC2 = DoubleVar(0)
366 ETS_TC2.set(0.03)
367 ETS_A2 = DoubleVar(0)
368 ETS_A2.set(5.0)
369 PhaseOffset1x = 37
370 PhaseOffset2x = 37
371 #('winnative', 'clam', 'alt', 'default', 'classic', 'vista', 'xpnative')
372 # 'aqua' built-in native Mac OS X only; Native Mac OS X
373 windowingsystem = root.tk.call('tk', 'windowingsystem')
374 ScreenWidth = root.winfo_screenwidth()
375 ScreenHeight = root.winfo_screenheight()
376 # print(str(ScreenWidth) + "X" + str(ScreenHeight))
377 if (root.tk.call('tk', 'windowingsystem')=='aqua'):
378  Style_String = 'aqua'
379  # On Macs, allow the dock icon to deiconify.
380  root.createcommand('::tk::mac::ReopenApplication', root.deiconify)
381  root.createcommand('::tk::mac::Quit', root.destroy)# Bcloseexit)
382  # On Macs, set up menu bar to be minimal.
383  root.option_add('*tearOff', False)
384  if sys.version_info[0] == 2:
385  menubar = tKinter.Menu(root)
386  appmenu = tKinter.Menu(menubar, name='apple')
387  else:
388  menubar = tkinter.Menu(root)
389  appmenu = tkinter.Menu(menubar, name='apple')
390  # menubar = tk.Menu(root)
391  # appmenu = tk.Menu(menubar, name='apple')
392  menubar.add_cascade(menu=appmenu)
393  # appmenu.add_command(label='Exit', command=Bcloseexit)
394  root['menu'] = menubar
395 else:
396  Style_String = 'alt'
397 # Check if there is an alice_init.ini file to read in
398 try:
399  import alice
400  import pathlib
401 # pathlib only available as standard in Python 3.4 and higher. For Python 2.7 must manually install package
402  path = pathlib.Path(alice.__file__).parent.absolute()
403  filename = os.path.join(path, "resources", InitFileName) # "alice_init.ini")
404  InitFile = open(filename)
405  for line in InitFile:
406  try:
407  exec( line.rstrip(), globals(), globals())
408  #exec( line.rstrip() )
409  except:
410  print("Skiping " + line.rstrip())
411  InitFile.close()
412 except:
413  try:
414  InitFile = open(InitFileName) # "alice_init.ini"
415  for line in InitFile:
416  try:
417  exec( line.rstrip(), globals(), globals())
418  #exec( line.rstrip() )
419  except:
420  print("Skiping " + line.rstrip())
421  InitFile.close()
422  except:
423  print( "No Init File Read. " + InitFileName + " Not Found")
424 #
425 XOLXY = X0L = FontSize * 7
426 XOLF = XOLBP = XOLIA = int(FontSize * 4.625)
427 XOLNqP = XOLNiC = int(FontSize * 3.125)
428 root.style = Style()
429 try:
430  root.style.theme_use(Style_String)
431 except:
432  root.style.theme_use('default')
433 if MouseFocus == 1:
434  root.tk_focusFollowsMouse()
435 #
436 DevID = "m1k"
437 #
438 if sys.version_info[0] == 2:
439  default_font = tkFont.nametofont("TkDefaultFont")
440 if sys.version_info[0] == 3:
441  default_font = tkinter.font.nametofont("TkDefaultFont")
442 default_font.configure(size=FontSize)
443 
444 CHvpdiv = (0.001, 0.002, 0.005, 0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1.0, 2.0, 5.0)
445 
446 CHipdiv = (0.1, 0.2, 0.5, 1.0, 2.0, 5.0, 10.0, 20.0, 50.0, 100.0, 200.0)
447 
448 SAMagdiv = ("10nV", "100nV", "1uV", "10uV", "100uV", "1mV", "10mV", "0.1", "1.0", "10.0")
449 
450 TMpdiv = (0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1.0, 2.0, 5.0, 10.0, 20.0, 50.0, 100.0, 200.0)
451 ResScalediv = (0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000)
452 SampRateList = (1024, 2048, 4096, 8194, 16393, 32787, 65574, 93023, 93385, 93750, 94118,
453  96385, 96774, 97166, 97561, 97959, 98361, 98765, 99174, 99585, 100000)
454 NoiseList =[ "None", "Uniform", "Gaussian"]
455 TIMEdiv = 0.5
456 RefPhase = ("CA-V", "CB-V", "CA-I", "CB-I")
457 
458 
459 AWGAAmplvalue = 0.0
460 AWGAOffsetvalue = 0.0
461 AWGAFreqvalue = 0.0
462 AWGAPhasevalue = 0
463 AWGAdelayvalue = 0
464 AWGADutyCyclevalue = 50
465 AWGAWave = 'dc'
466 AWGBAmplvalue = 0.0
467 AWGBOffsetvalue = 0.0
468 AWGBFreqvalue = 0.0
469 AWGBPhasevalue = 0
470 AWGBdelayvalue = 0
471 AWGBDutyCyclevalue = 50
472 AWGBWave = 'dc'
473 AWGACycles = 1
474 AWGBCycles = 1
475 AWGABurstDelay = 0
476 AWGBBurstDelay = 0
477 Reset_Freq = 300
478 MeasGateLeft = 0.0
479 MeasGateRight = 0.0 # in mSec
480 MeasGateNum = 0
481 MeasGateStatus = IntVar(0)
482 MeasGateStatus.set(0)
483 #
484 DCV1 = DCV2 = MinV1 = MaxV1 = MinV2 = MaxV2 = MidV1 = PPV1 = MidV2 = PPV2 = SV1 = SI1 = 0
485 
486 DCVMuxA = MinVMuxA = MaxVMuxA = MidVMuxA = PPVMuxA = SVMuxA = 0
487 DCVMuxB = MinVMuxB = MaxVMuxB = MidVMuxB = PPVMuxB = SVMuxB = 0
488 DCVMuxC = MinVMuxC = MaxVMuxC = MidVMuxC = PPVMuxC = SVMuxC = 0
489 DCVMuxD = MinVMuxD = MaxVMuxD = MidVMuxD = PPVMuxD = SVMuxD = 0
490 PeakVA = PeakVB = PeakVAB = PeakIA = PeakIB = PeakIAB = 0.0
491 PeakVMA = PeakVMB = PeakVMC = PeakVMD = 0.0
492 PeakphaseVMA = PeakphaseVMB = PeakphaseVMC = PeakphaseVMD = 0.0
493 PeakfreqVA = PeakfreqVB = PeakfreqIA = PeakfreqIB = PeakfreqIAB = 0.0
494 PeakphaseVA = PeakphaseVB = PeakphaseIA = PeakphaseIB = PeakphaseVAB = PeakphaseIAB = 0.0
495 CHADCy = CHBDCy = 0
496 DCI1 = DCI2 = MinI1 = MaxI1 = MinI2 = MaxI2 = MidI1 = PPI1 = MidI2 = PPI2 = SV2 = SI2 = 0
497 CHAperiod = CHAfreq = CHBperiod = CHBfreq = 0
498 # Calibration coefficients
499 CHAVGain = CHBVGain = 1.0
500 CHAVOffset = CHBVOffset = 0.0
501 # Initialisation of general variables
502 CHAOffset = CHBOffset = CHBAOffset = CHBBOffset = CHBCOffset = CHBDOffset = 2.5
503 CHAIOffset = CHBIOffset = InOffA = InGainA = InOffB = InGainB = 0.0
504 # Other global variables required in various routines
505 CANVASwidth = GRW + 2 * X0L # The canvas width
506 CANVASheight = GRH + Y0T + (FontSize * 7) # The canvas height
507 
508 ADsignal1 = [] # Ain signal array channel A and B
509 VBuffA = []
510 VBuffB = []
511 IBuffA = []
512 IBuffB = []
513 VBuffMA = []
514 VBuffMB = []
515 VBuffMC = []
516 VBuffMD = []
517 VmemoryMuxA = []
518 VmemoryMuxB = []
519 VmemoryMuxC = []
520 VmemoryMuxD = []
521 #
522 VUnAvgA = []
523 VUnAvgB = []
524 IUnAvgA = []
525 IUnAvgB = []
526 #
527 DBuff0 = []
528 DBuff1 = []
529 DBuff2 = []
530 DBuff3 = []
531 #
532 VAresult = []
533 VBresult = []
534 IAresult = []
535 IBresult = []
536 IABresult = []
537 PhaseIA = []
538 PhaseIB = []
539 PhaseIAB = []
540 PhaseVA = []
541 PhaseVB = []
542 DFiltACoef = [1]
543 DFiltBCoef = [1]
544 DigFiltA = IntVar(0)
545 DigFiltA.set(0)
546 DigFiltABoxCar = IntVar(0)
547 DigFiltBBoxCar = IntVar(0)
548 DigDeSkewA = IntVar(0)
549 DigDeSkewB = IntVar(0)
550 DigFiltB = IntVar(0)
551 DigFiltB.set(0)
552 DigBuffA = IntVar(0)
553 DigBuffB = IntVar(0)
554 DigBuffA.set(0)
555 DigBuffB.set(0)
556 AWGFiltA = IntVar(0)
557 AWGFiltB = IntVar(0)
558 AWGFiltABoxCar = IntVar(0)
559 AWGFiltBBoxCar = IntVar(0)
560 AWGFiltACoef = [1]
561 AWGFiltBCoef = [1]
562 VFilterA = {}
563 VFilterB = {}
564 SampleRateStatus = IntVar(0)
565 ETSStatus = IntVar(0)
566 ETSDisp = IntVar(0)
567 ETSDir = IntVar(0)
568 #
569 AWGAwaveform = []
570 AWGA2X = [] # array for odd numbers samples when in 2x sample rate
571 AWGBwaveform = []
572 AWGB2X = [] # array for odd numbers samples when in 2x sample rate
573 VmemoryA = numpy.ones(1) # The memory for averaging
574 VmemoryB = numpy.ones(1)
575 ImemoryA = numpy.ones(1) # The memory for averaging
576 ImemoryB = numpy.ones(1)
577 TRACEresetTime = True # True for first new trace, false for averageing
578 TRACEresetFreq = True # True for first new trace, false for averageing
579 AWGScreenStatus = IntVar(0)
580 
581 T1Vline = [] # Voltage Trace line channel A
582 T2Vline = [] # Voltage Trace line channel B
583 T1Iline = [] # Current Trace line channel A
584 T2Iline = [] # Current Trace line channel B
585 TMAVline = [] # Voltage Trace line MUX channel A
586 TMBVline = [] # Voltage Trace line MUX channel B
587 TMCVline = [] # Voltage Trace line MUX channel C
588 TMDVline = [] # Voltage Trace line MUX channel D
589 TMARline = [] # V reference Trace line MUX channel A
590 TMBRline = [] # V reference Trace line MUX channel B
591 TMCRline = [] # V reference line MUX channel C
592 TMDRline = [] # V reference line MUX channel D
593 XYlineVA = [] # XY Trace lines
594 XYlineVB = []
595 XYlineIA = []
596 XYlineIB = []
597 XYlineM = []
598 XYlineMX = []
599 XYlineMY = []
600 XYRlineVA = [] # XY reference trace lines
601 XYRlineVB = []
602 XYRlineIA = []
603 XYRlineIB = []
604 XYRlineM = []
605 XYRlineMX = []
606 XYRlineMY = []
607 Tmathline = [] # Time Math trace line
608 TMXline = [] # Time X math Trace line
609 TMYline = [] # Time Y math Trace line
610 T1VRline = [] # V reference Trace line channel A
611 T2VRline = [] # V reference Trace line channel B
612 T1IRline = [] # I reference Trace line channel A
613 T2IRline = [] # I reference Trace line channel B
614 TMRline = [] # Math reference Trace line
615 D0line = [] # Digital input 0 Trace line
616 D1line = [] # Digital input 1 Trace line
617 D2line = [] # Digital input 2 Trace line
618 D3line = [] # Digital input 3 Trace line
619 Triggerline = [] # Triggerline
620 Triggersymbol = [] # Trigger symbol
621 #
622 SHOWsamples = 4000 # Number of samples on the screen
623 SCstart = 0 # Start sample of the trace
624 HozPoss = 0.0
625 Is_Triggered = 0
626 #
627 TRACES = 1 # Number of traces 1 or 2
628 TRACESread = 0 # Number of traces that have been read from ALM
629 ScreenTrefresh = IntVar(0)
630 ScreenXYrefresh = IntVar(0)
631 #
632 NSteps = IntVar(0) # number of frequency sweep steps
633 NSteps.set(128)
634 LoopNum = IntVar(0)
635 LoopNum.set(1)
636 LastWindow = -1
637 LastSMPfft = 0
638 CurrentFreqX = X0LBP + 14
639 FBins = numpy.linspace(0, 50000, num=16384)
640 FStep = numpy.linspace(0, 16384, num=NSteps.get())
641 FSweepMode = IntVar(0)
642 FSweepCont = IntVar(0)
643 FStepSync = IntVar(0)
644 FSweepSync = IntVar(0)
645 ShowCA_VdB = IntVar(0) # curves to display variables
646 ShowCA_P = IntVar(0)
647 ShowCB_VdB = IntVar(0)
648 ShowCB_P = IntVar(0)
649 ShowMarkerBP = IntVar(0)
650 ShowCA_RdB = IntVar(0)
651 ShowCA_RP = IntVar(0)
652 ShowCB_RdB = IntVar(0)
653 ShowCB_RP = IntVar(0)
654 ShowMathBP = IntVar(0)
655 ShowRMathBP = IntVar(0)
656 SingleShotSA = IntVar(0) # variable for Single Shot sweeps
657 FSweepAdB = []
658 FSweepBdB = []
659 FSweepAPh = []
660 FSweepBPh = []
661 NSweepSeriesR = []
662 NSweepSeriesX = []
663 NSweepSeriesMag = [] # in ohms
664 NSweepSeriesAng = [] # in degrees
665 NSweepParallelR = []
666 NSweepParallelC = []
667 NSweepParallelL = []
668 NSweepSeriesC = []
669 NSweepSeriesL = []
670 NetworkScreenStatus = IntVar(0)
671 BDSweepFile = IntVar(0)
672 FileSweepFreq = []
673 FileSweepAmpl = []
674 #
675 MarkerNum = MarkerFreqNum = 0
676 ShowTCur = IntVar(0)
677 ShowVCur = IntVar(0)
678 TCursor = VCursor = 0
679 ShowXCur = IntVar(0)
680 ShowYCur = IntVar(0)
681 XCursor = YCursor = 0
682 ShowFCur = IntVar(0)
683 ShowdBCur = IntVar(0)
684 FCursor = dBCursor = 0
685 ShowBPCur = IntVar(0)
686 ShowBdBCur = IntVar(0)
687 BPCursor = BdBCursor = 0
688 RUNstatus = IntVar(0) # 0 stopped, 1 start, 2 running, 3 stop and restart, 4 stop
689 PowerStatus = 1
690 TRIGGERsample = 0 # AD sample trigger point
691 DX = 0 # interpolated trigger point
692 
693 DBdivlist = [1, 2, 3, 5, 10, 15, 20] # dB per division
694 DBdivindex = IntVar(0) # 10 dB/div as initial value
695 DBdivindex.set(4)
696 DBlevel = IntVar(0) # Reference level
697 DBlevel.set(0)
698 DBdivindexBP = IntVar(0) # 10 dB/div as initial value
699 DBdivindexBP.set(4)
700 DBlevelBP = IntVar(0) # Reference level
701 DBlevelBP.set(0)
702 hldn = 0
703 SpectrumScreenStatus = IntVar(0)
704 SmoothCurvesSA = IntVar(0)
705 SmoothCurvesBP = IntVar(0)
706 CutDC = IntVar(0)
707 IAScreenStatus = IntVar(0)
708 NqPScreenStatus = IntVar(0)
709 NqPDisp = IntVar(0)
710 NiCScreenStatus = IntVar(0)
711 NiCDisp = IntVar(0)
712 ImpedanceMagnitude = 0.0 # in ohms
713 ImpedanceAngle = 0.0 # in degrees
714 ImpedanceRseries = 0.0 # in ohms
715 ImpedanceXseries = 0.0 # in ohms
716 Show_Rseries = IntVar(0)
717 Show_Xseries = IntVar(0)
718 Show_Magnitude = IntVar(0)
719 Show_Angle = IntVar(0)
720 Show_RseriesRef = IntVar(0)
721 Show_XseriesRef = IntVar(0)
722 Show_MagnitudeRef = IntVar(0)
723 Show_AngleRef = IntVar(0)
724 
725 TIARline = []
726 TIAXline = []
727 TIAMagline = []
728 TIAAngline = []
729 TIAMline = []
730 TIAMRline = []
731 RefIARline = []
732 RefIAXline = []
733 RefIAMagline = []
734 RefIAAngline = []
735 IASource = IntVar(0)
736 IAGridType = IntVar(0)
737 
738 DisplaySeries = IntVar(0)
739 IA_Ext_Conf = IntVar(0)
740 IASweepSaved = IntVar(0)
741 OverRangeFlagA = 0
742 OverRangeFlagB = 0
743 PeakdbA = 10
744 PeakdbB = 10
745 PeakRelPhase = 0.0
746 PeakfreqA = 100
747 PeakfreqB = 1000
748 OhmStatus = IntVar(0)
749 OhmRunStatus = IntVar(0)
750 FFTbandwidth = 0 # The FFT bandwidth
751 FFTBuffA = [] # Clear the FFTBuff array for trace A
752 FFTBuffB = [] # Clear the FFTBuff array for trace B
753 FFTresultA = [] # FFT result CHA
754 PhaseA = []
755 FFTresultB = [] # FFT result CHB
756 PhaseB = []
757 FFTresultAB = []
758 FFTwindowname = "--" # The FFT window name
759 FFTmemoryA = numpy.ones(1) # The memory for averaging
760 PhaseMemoryA = numpy.ones(1)
761 FFTmemoryB = numpy.ones(1) # The memory for averaging
762 PhaseMemoryB = numpy.ones(1)
763 SMPfftpwrTwo = IntVar(0) # The power of two of SMPfft
764 SMPfftpwrTwo.set(11)
765 SMPfft = 2 ** SMPfftpwrTwo.get() # Initialize
766 Two28 = 268435456
767 FFTwindowshape = numpy.ones(SMPfft) # The FFT window curve
768 
769 T1Fline = [] # Frequency Trace line channel A
770 T2Fline = [] # Frequency Trace line channel B
771 T1Pline = [] # Phase angle Trace line channel A - B
772 T2Pline = [] # Phase angle Trace line channel B - A
773 T1FRline = [] # F reference Trace line channel A
774 T2FRline = [] # F reference Trace line channel B
775 T1PRline = [] # Phase reference Trace line channel A - B
776 T2PRline = [] # Phase reference Trace line channel B - A
777 TFMline = [] # Frequency Math Trace
778 TFRMline = [] # Frequency reference Math Trace
779 FreqTraceMode = IntVar(0) # 1 normal mode, 2 max hold mode, 3 average mode
780 FreqTraceMode.set(1)
781 
782 TAFline = [] # Bode Freq Trace line channel A
783 TBFline = [] # Bode Freq Trace line channel B
784 TAPline = [] # Bode Phase angle Trace line channel A - B
785 TBPline = [] # Bode Phase angle Trace line channel B - A
786 TAFRline = [] # Bode F reference Trace line channel A
787 TBFRline = [] # Bode F reference Trace line channel B
788 TAPRline = [] # Bode Phase reference Trace line channel A - B
789 TBPRline = [] # Bode Phase reference Trace line channel B - A
790 TBPMline = [] # Bode Frequency Math Trace
791 TBPRMline = [] # Bode Frequency reference Math Trace
792 #
793 MinSamplesSA = 64
794 MaxSamplesSA = 65536
795 #
796 MathScreenStatus = IntVar(0)
797 ColorScreenStatus = IntVar(0)
798 XYScreenStatus = IntVar(0)
799 Xsignal = IntVar(0) # Signal for X axis variable
800 Xsignal.set(1)
801 YsignalVA = IntVar(0) # Signal for Y axis variable
802 YsignalVB = IntVar(0)
803 YsignalIA = IntVar(0)
804 YsignalIB = IntVar(0)
805 YsignalM = IntVar(0)
806 YsignalMX = IntVar(0)
807 YsignalMY = IntVar(0)
808 YsignalVB.set(1)
809 XYRefAV = IntVar(0) # show reference XY traces
810 XYRefBV = IntVar(0)
811 XYRefAI = IntVar(0)
812 XYRefBI = IntVar(0)
813 XYRefM = IntVar(0)
814 XYRefMX = IntVar(0)
815 XYRefMY = IntVar(0)
816 # show Analog Input Mux Variables
817 Show_CBA = IntVar(0)
818 Show_CBB = IntVar(0)
819 Show_CBC = IntVar(0)
820 Show_CBD = IntVar(0)
821 ShowRMA = IntVar(0)
822 ShowRMB = IntVar(0)
823 ShowRMC = IntVar(0)
824 ShowRMD = IntVar(0)
825 D0 = IntVar(0)
826 D1 = IntVar(0)
827 D2 = IntVar(0)
828 D3 = IntVar(0)
829 D4 = IntVar(0)
830 D5 = IntVar(0)
831 D6 = IntVar(0)
832 D7 = IntVar(0)
833 D0.set(0x50)
834 D1.set(0x50)
835 D2.set(0x50)
836 D3.set(0x50)
837 D4.set(0x50)
838 D5.set(0x50)
839 D6.set(0x50)
840 D7.set(0x50)
841 PIO_0 = 28
842 PIO_1 = 29
843 PIO_2 = 47
844 PIO_3 = 3
845 PIO_4 = 4
846 PIO_5 = 5
847 PIO_6 = 6
848 PIO_7 = 7
849 #
850 SCLKPort = IntVar(0)
851 SDATAPort = IntVar(0)
852 SLATCHPort = IntVar(0)
853 
854 
855 hipulse = """
856 R0lGODlhGQAYAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A/wD/
857 /////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
858 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMwAAZgAAmQAAzAAA/wAzAAAzMwAzZgAzmQAzzAAz/wBm
859 AABmMwBmZgBmmQBmzABm/wCZAACZMwCZZgCZmQCZzACZ/wDMAADMMwDMZgDMmQDMzADM/wD/AAD/
860 MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMzADMzMzMzZjMzmTMzzDMz/zNmADNmMzNm
861 ZjNmmTNmzDNm/zOZADOZMzOZZjOZmTOZzDOZ/zPMADPMMzPMZjPMmTPMzDPM/zP/ADP/MzP/ZjP/
862 mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YzAGYzM2YzZmYzmWYzzGYz/2ZmAGZmM2ZmZmZmmWZm
863 zGZm/2aZAGaZM2aZZmaZmWaZzGaZ/2bMAGbMM2bMZmbMmWbMzGbM/2b/AGb/M2b/Zmb/mWb/zGb/
864 /5kAAJkAM5kAZpkAmZkAzJkA/5kzAJkzM5kzZpkzmZkzzJkz/5lmAJlmM5lmZplmmZlmzJlm/5mZ
865 AJmZM5mZZpmZmZmZzJmZ/5nMAJnMM5nMZpnMmZnMzJnM/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwA
866 M8wAZswAmcwAzMwA/8wzAMwzM8wzZswzmcwzzMwz/8xmAMxmM8xmZsxmmcxmzMxm/8yZAMyZM8yZ
867 ZsyZmcyZzMyZ/8zMAMzMM8zMZszMmczMzMzM/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8A
868 mf8AzP8A//8zAP8zM/8zZv8zmf8zzP8z//9mAP9mM/9mZv9mmf9mzP9m//+ZAP+ZM/+ZZv+Zmf+Z
869 zP+Z///MAP/MM//MZv/Mmf/MzP/M////AP//M///Zv//mf//zP///ywAAAAAGQAYAAAIZwAfCBxI
870 sKDBgw8AKFzIsKFChA4jMoQoUSJFAAgHLryYUeDGgx8zhiw4EuRDkxg7ltR4UmRLki9RclQZk2VK
871 lzdh5pTJE+dMnz1/6uyYsKZHowRXHt1pcGREohUbQo2qNKlDolgFBgQAOw==
872 """
873 hipulseimg = PhotoImage(data=hipulse)
874 
875 lowpulse = """
876 R0lGODlhGQAYAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A/wD/
877 /////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
878 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMwAAZgAAmQAAzAAA/wAzAAAzMwAzZgAzmQAzzAAz/wBm
879 AABmMwBmZgBmmQBmzABm/wCZAACZMwCZZgCZmQCZzACZ/wDMAADMMwDMZgDMmQDMzADM/wD/AAD/
880 MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMzADMzMzMzZjMzmTMzzDMz/zNmADNmMzNm
881 ZjNmmTNmzDNm/zOZADOZMzOZZjOZmTOZzDOZ/zPMADPMMzPMZjPMmTPMzDPM/zP/ADP/MzP/ZjP/
882 mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YzAGYzM2YzZmYzmWYzzGYz/2ZmAGZmM2ZmZmZmmWZm
883 zGZm/2aZAGaZM2aZZmaZmWaZzGaZ/2bMAGbMM2bMZmbMmWbMzGbM/2b/AGb/M2b/Zmb/mWb/zGb/
884 /5kAAJkAM5kAZpkAmZkAzJkA/5kzAJkzM5kzZpkzmZkzzJkz/5lmAJlmM5lmZplmmZlmzJlm/5mZ
885 AJmZM5mZZpmZmZmZzJmZ/5nMAJnMM5nMZpnMmZnMzJnM/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwA
886 M8wAZswAmcwAzMwA/8wzAMwzM8wzZswzmcwzzMwz/8xmAMxmM8xmZsxmmcxmzMxm/8yZAMyZM8yZ
887 ZsyZmcyZzMyZ/8zMAMzMM8zMZszMmczMzMzM/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8A
888 mf8AzP8A//8zAP8zM/8zZv8zmf8zzP8z//9mAP9mM/9mZv9mmf9mzP9m//+ZAP+ZM/+ZZv+Zmf+Z
889 zP+Z///MAP/MM//MZv/Mmf/MzP/M////AP//M///Zv//mf//zP///ywAAAAAGQAYAAAIZwAfCBxI
890 sKBBggASKgRwEOHChwsbDoRIkaHEBxQdWpSosGHHix8NhvSYkORGkyhBljw4kuVKkS9TwjzpkubE
891 mDVl6tR4ESPOmzYLtgTac6hAozxzqgzqkynRmhUhmoz6cCpVpD0vBgQAOw==
892 """
893 lowpulseimg = PhotoImage(data=lowpulse)
894 
895 class CreateToolTip(object):
896 
897  def __init__(self, widget, text='widget info'):
898  self.waittime = 500 #miliseconds
899  self.wraplength = 100 #pixels
900  self.widget = widget
901  self.text = text
902  self.widget.bind("<Enter>", self.enter)
903  self.widget.bind("<Leave>", self.leave)
904  self.widget.bind("<ButtonPress>", self.leave)
905  self.id = None
906  self.tw = None
907 
908  def enter(self, event=None):
909  self.schedule()
910 
911  def leave(self, event=None):
912  self.unschedule()
913  self.hidetip()
914 
915  def schedule(self):
916  self.unschedule()
917  self.id = self.widget.after(self.waittime, self.showtip)
918 
919  def unschedule(self):
920  id = self.id
921  self.id = None
922  if id:
923  self.widget.after_cancel(id)
924 
925  def showtip(self, event=None):
926  x = y = 0
927  x, y, cx, cy = self.widget.bbox("insert")
928  x += self.widget.winfo_rootx() + 25
929  y += self.widget.winfo_rooty() + 20
930  # creates a toplevel window
931  self.tw = Toplevel(self.widget)
932  # Leaves only the label and removes the app window
933  self.tw.wm_overrideredirect(True)
934  self.tw.wm_geometry("+%d+%d" % (x, y))
935  label = Label(self.tw, text=self.text, justify='left',
936  background="#ffffe0", foreground="#000000",
937  relief='solid', borderwidth=1,
938  wraplength = self.wraplength)
939  label.pack(ipadx=1)
940 
941  def hidetip(self):
942  tw = self.tw
943  self.tw= None
944  if tw:
945  tw.destroy()
946 
947  def configure(self, text):
948  self.text = text
949 #
950 # =========== Start widgets routines =============================
951 
953 def BSaveConfig(filename):
954  global TgInput, TgEdge, ManualTrigger, SingleShot, AutoLevel, SingleShotSA
955  global root, freqwindow, awgwindow, iawindow, xywindow, win1, win2
956  global TRIGGERentry, TMsb, Xsignal, AutoCenterA, AutoCenterB
957  global YsignalVA, YsignalIA, YsignalVB, YsignalIB, YsignalM, YsignalMX, YsignalMY
958  global CHAsb, CHAIsb, CHBsb, CHBIsb, HScale, FreqTraceMode
959  global CHAsbxy, CHAIsbxy, CHBsbxy, CHBIsbxy, HoldOffentry
960  global CHAVPosEntryxy, CHBVPosEntryxy, CHAIPosEntryxy, CHBIPosEntryxy
961  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, MathTrace, MathXUnits, MathYUnits
962  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry
963  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGADutyCycleEntry
964  global AWGAPhaseEntry, AWGAShape, AWGATerm, AWGAMode, AWGARepeatFlag, AWGBRepeatFlag
965  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBDutyCycleEntry
966  global AWGBPhaseEntry, AWGBShape, AWGBTerm, AWGBMode, AWGSync, AWGAIOMode, AWGBIOMode
967  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
968  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1, MeasDCI1, MeasMinI1
969  global MeasMaxI1, MeasMidI1, MeasPPI1, MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2
970  global MeasPPV2, MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2, MeasDiffAB, MeasDiffBA
971  global MeasRMSV1, MeasRMSV2, MeasRMSI1, MeasRMSI2, MeasPhase
972  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ, IASource, DisplaySeries
973  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
974  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
975  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, CutDC, DacScreenStatus, DigScreenStatus
976  global FFTwindow, DBdivindex, DBlevel, TRACEmodeTime, TRACEaverage, Vdiv
977  global SMPfftpwrTwo, SMPfft, StartFreqEntry, StopFreqEntry, ZEROstuffing
978  global TimeDisp, XYDisp, FreqDisp, IADisp, XYScreenStatus, IAScreenStatus, SpectrumScreenStatus
979  global RsystemEntry, ResScale, GainCorEntry, PhaseCorEntry, AWGAPhaseDelay, AWGBPhaseDelay
980  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2, MeasDelay
981  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxScreenStatus, MuxEnb, ChopMuxMode, ChopTrig, DualMuxMode
982  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry, muxwindow
983  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry, HozPossentry
984  global SmoothCurvesBP, bodewindow, AWG_Amp_Mode, ColorMode
985  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, ShowMarkerBP, BodeDisp
986  global ShowCA_RdB, ShowCA_RP, ShowCB_RdB, ShowCB_RP, ShowMathBP, ShowRMathBP
987  global BPSweepMode, BPSweepCont, BodeScreenStatus, RevDate, SweepStepBodeEntry
988  global HScaleBP, StopBodeEntry, StartBodeEntry, ShowBPCur, ShowBdBCur, BPCursor, BdBCursor
989  global MathString, MathXString, MathYString, UserAString, UserALabel, UserBString, UserBLabel
990  global MathAxis, MathXAxis, MathYAxis, Show_MathX, Show_MathY, MathScreenStatus, MathWindow
991  global AWGAMathString, AWGBMathString, FFTUserWindowString, DigFilterAString, DigFilterBString
992  global GRWF, GRHF, GRWBP, GRHBP, GRWXY, GRHXY, GRWIA, GRHIA, MeasureStatus
993  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
994  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
995  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
996  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
997  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2, CHAI_RC_HP, CHBI_RC_HP
998  global CHA_A1, CHA_A2, CHB_A1, CHB_A2, RelPhaseCenter, ImpedanceCenter, NetworkScreenStatus
999  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
1000  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
1001  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
1002  global AWGABurstFlag, AWGACycles, AWGABurstDelay, AWGAcsvFile, AWGBcsvFile
1003  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay, AWGAwavFile, AWGBwavFile
1004  global SCLKPort, SDATAPort, SLATCHPort, EnableHSsampling, FminEntry, HtMulEntry
1005  global Auto_ETS_Comp, ETS_TC1, ETS_A1, ETS_TC2, ETS_A2
1006  global ets_TC1Entry, ets_A1Entry, ets_TC2Entry, ets_A2Entry
1007  global DigFiltStatus, DigFiltABoxCar, DigFiltBBoxCar, BCALenEntry, BCBLenEntry
1008  global phawindow, PhAca, PhAScreenStatus, PhADisp
1009  global GRWPhA, X0LPhA, GRHPhA, Y0TPhA, BoardStatus, boardwindow, BrdSel
1010  global VScale, IScale, RefphEntry, EnableScopeOnly, Roll_Mode
1011  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn, iapbt_btn
1012  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D, ScreenWidth, ScreenHeight
1013  global AWGANoiseEntry, AWGBNoiseEntry, AWGAsbnoise, AWGBsbnoise
1014  global AWGFiltA, AWGALenEntry, AWGFiltABoxCar, AWGFiltALength, digfltwindow
1015  global AWGFiltB, AWGBLenEntry, AWGFiltBBoxCar, AWGFiltBLength
1016  global COLORtext, COLORcanvas, COLORtrigger, COLORsignalband, COLORframes, COLORgrid, COLORzeroline
1017  global COLORtrace1, COLORtraceR1, COLORtrace2, COLORtraceR2, COLORtrace3, COLORtraceR3, COLORtrace4, COLORtraceR4
1018  global COLORtrace5, COLORtraceR5, COLORtrace6, COLORtraceR6, COLORtrace7, COLORtraceR7
1019  # open Config file for Write?
1020  try:
1021  ConfgFile = open(filename, "w")
1022  except: # didn't work? then just return
1023  return
1024  # Save Window placements
1025  ConfgFile.write("root.geometry('+" + str(root.winfo_x()) + '+' + str(root.winfo_y()) + "')\n")
1026  if EnableScopeOnly == 0:
1027  ConfgFile.write("awgwindow.geometry('+" + str(awgwindow.winfo_x()) + '+' + str(awgwindow.winfo_y()) + "')\n")
1028  ConfgFile.write('GRW = ' + str(GRW) + '\n')
1029  ConfgFile.write('GRH = ' + str(GRH) + '\n')
1030  ConfgFile.write('ColorMode.set(' + str(ColorMode.get()) + ')\n')
1031  # Windows configuration
1032  ConfgFile.write('MathString = "' + MathString + '"\n')
1033  ConfgFile.write('MathUnits = "' + MathUnits + '"\n')
1034  ConfgFile.write('MathAxis = "' + MathAxis + '"\n')
1035  ConfgFile.write('MathXString = "' + MathXString + '"\n')
1036  ConfgFile.write('MathXUnits = "' + MathXUnits + '"\n')
1037  ConfgFile.write('MathXAxis = "' + MathXAxis + '"\n')
1038  ConfgFile.write('MathYString = "' + MathYString + '"\n')
1039  ConfgFile.write('MathYUnits = "' + MathYUnits + '"\n')
1040  ConfgFile.write('MathYAxis = "' + MathYAxis + '"\n')
1041  # Save Color Def
1042  ConfgFile.write('COLORtext = "' + COLORtext + '"\n')
1043  ConfgFile.write('COLORcanvas = "' + COLORcanvas + '"\n')
1044  ConfgFile.write('COLORtrigger = "' + COLORtrigger + '"\n')
1045  ConfgFile.write('COLORsignalband = "' + COLORsignalband + '"\n')
1046  ConfgFile.write('COLORframes = "' + COLORframes + '"\n')
1047  ConfgFile.write('COLORgrid = "' + COLORgrid + '"\n')
1048  ConfgFile.write('COLORtrace1 = "' + COLORtrace1 + '"\n')
1049  ConfgFile.write('COLORtraceR1 = "' + COLORtraceR1 + '"\n')
1050  ConfgFile.write('COLORtrace2 = "' + COLORtrace2 + '"\n')
1051  ConfgFile.write('COLORtraceR2 = "' + COLORtraceR2 + '"\n')
1052  ConfgFile.write('COLORtrace3 = "' + COLORtrace3 + '"\n')
1053  ConfgFile.write('COLORtraceR3 = "' + COLORtraceR3 + '"\n')
1054  ConfgFile.write('COLORtrace4 = "' + COLORtrace4 + '"\n')
1055  ConfgFile.write('COLORtraceR4 = "' + COLORtraceR4 + '"\n')
1056  ConfgFile.write('COLORtrace5 = "' + COLORtrace5 + '"\n')
1057  ConfgFile.write('COLORtraceR5 = "' + COLORtraceR5 + '"\n')
1058  ConfgFile.write('COLORtrace6 = "' + COLORtrace6 + '"\n')
1059  ConfgFile.write('COLORtraceR6 = "' + COLORtraceR6 + '"\n')
1060  ConfgFile.write('COLORtrace7 = "' + COLORtrace7 + '"\n')
1061  ConfgFile.write('COLORtraceR7 = "' + COLORtraceR7 + '"\n')
1062  #
1063  if BoardStatus.get() > 0:
1064  ConfgFile.write('MakeBoardScreen()\n')
1065  ConfgFile.write("boardwindow.geometry('+" + str(boardwindow.winfo_x()) + '+' + str(boardwindow.winfo_y()) + "')\n")
1066  ConfgFile.write('BrdSel.set(' + str(BrdSel.get()) + ')\n')
1067  ConfgFile.write('SelectBoard()\n')
1068  else:
1069  ConfgFile.write('DestroyBoardScreen()\n')
1070  if MathScreenStatus.get() > 0:
1071  ConfgFile.write('NewEnterMathControls()\n')
1072  ConfgFile.write("MathWindow.geometry('+" + str(MathWindow.winfo_x()) + '+' + str(MathWindow.winfo_y()) + "')\n")
1073  else:
1074  ConfgFile.write('DestroyMathScreen()\n')
1075  if XYScreenStatus.get() > 0:
1076  ConfgFile.write('GRWXY = ' + str(GRWXY) + '\n')
1077  ConfgFile.write('GRHXY = ' + str(GRHXY) + '\n')
1078  ConfgFile.write('MakeXYWindow()\n')
1079  ConfgFile.write("xywindow.geometry('+" + str(xywindow.winfo_x()) + '+' + str(xywindow.winfo_y()) + "')\n")
1080  ConfgFile.write('CHAsbxy.delete(0,END)\n')
1081  ConfgFile.write('CHAsbxy.insert(0, ' + CHAsbxy.get() + ')\n')
1082  ConfgFile.write('CHAIsbxy.delete(0,END)\n')
1083  ConfgFile.write('CHAIsbxy.insert(0, ' + CHAIsbxy.get() + ')\n')
1084  ConfgFile.write('CHAVPosEntryxy.delete(0,END)\n')
1085  ConfgFile.write('CHAVPosEntryxy.insert(4, ' + CHAVPosEntryxy.get() + ')\n')
1086  ConfgFile.write('CHAIPosEntryxy.delete(0,END)\n')
1087  ConfgFile.write('CHAIPosEntryxy.insert(4, ' + CHAIPosEntryxy.get() + ')\n')
1088  ConfgFile.write('CHBsbxy.delete(0,END)\n')
1089  ConfgFile.write('CHBsbxy.insert(0, ' + CHBsbxy.get() + ')\n')
1090  ConfgFile.write('CHBIsbxy.delete(0,END)\n')
1091  ConfgFile.write('CHBIsbxy.insert(0, ' + CHBIsbxy.get() + ')\n')
1092  ConfgFile.write('CHBVPosEntryxy.delete(0,END)\n')
1093  ConfgFile.write('CHBVPosEntryxy.insert(4, ' + CHBVPosEntryxy.get() + ')\n')
1094  ConfgFile.write('CHBIPosEntryxy.delete(0,END)\n')
1095  ConfgFile.write('CHBIPosEntryxy.insert(4, ' + CHBIPosEntryxy.get() + ')\n')
1096  else:
1097  ConfgFile.write('DestroyXYScreen()\n')
1098  if IAScreenStatus.get() > 0:
1099  ConfgFile.write('GRWIA = ' + str(GRWIA) + '\n')
1100  ConfgFile.write('GRHIA = ' + str(GRHIA) + '\n')
1101  ConfgFile.write('MakeIAWindow()\n')
1102  ConfgFile.write("iawindow.geometry('+" + str(iawindow.winfo_x()) + '+' + str(iawindow.winfo_y()) + "')\n")
1103  ConfgFile.write('IASource.set(' + str(IASource.get()) + ')\n')
1104  ConfgFile.write('DisplaySeries.set(' + str(DisplaySeries.get()) + ')\n')
1105  ConfgFile.write('RsystemEntry.delete(0,END)\n')
1106  ConfgFile.write('RsystemEntry.insert(5, ' + RsystemEntry.get() + ')\n')
1107  ConfgFile.write('ResScale.delete(0,END)\n')
1108  ConfgFile.write('ResScale.insert(5, ' + ResScale.get() + ')\n')
1109  ConfgFile.write('GainCorEntry.delete(0,END)\n')
1110  ConfgFile.write('GainCorEntry.insert(5, ' + GainCorEntry.get() + ')\n')
1111  ConfgFile.write('PhaseCorEntry.delete(0,END)\n')
1112  ConfgFile.write('PhaseCorEntry.insert(5, ' + PhaseCorEntry.get() + ')\n')
1113  ConfgFile.write('NetworkScreenStatus.set(' + str(NetworkScreenStatus.get()) + ')\n')
1114  else:
1115  ConfgFile.write('DestroyIAScreen()\n')
1116  if SpectrumScreenStatus.get() > 0:
1117  ConfgFile.write('GRWF = ' + str(GRWF) + '\n')
1118  ConfgFile.write('GRHF = ' + str(GRHF) + '\n')
1119  ConfgFile.write('RelPhaseCenter.set(' + str(RelPhaseCenter.get()) + ')\n')
1120  ConfgFile.write('MakeSpectrumWindow()\n')
1121  ConfgFile.write("freqwindow.geometry('+" + str(freqwindow.winfo_x()) + '+' + str(freqwindow.winfo_y()) + "')\n")
1122  ConfgFile.write('ShowC1_VdB.set(' + str(ShowC1_VdB.get()) + ')\n')
1123  ConfgFile.write('ShowC1_P.set(' + str(ShowC1_P.get()) + ')\n')
1124  ConfgFile.write('ShowC2_VdB.set(' + str(ShowC2_VdB.get()) + ')\n')
1125  ConfgFile.write('ShowC2_P.set(' + str(ShowC2_P.get()) + ')\n')
1126  ConfgFile.write('StartFreqEntry.delete(0,END)\n')
1127  ConfgFile.write('StartFreqEntry.insert(5, ' + StartFreqEntry.get() + ')\n')
1128  ConfgFile.write('StopFreqEntry.delete(0,END)\n')
1129  ConfgFile.write('StopFreqEntry.insert(5, ' + StopFreqEntry.get() + ')\n')
1130  ConfgFile.write('HScale.set(' + str(HScale.get()) + ')\n')
1131  ConfgFile.write('FreqTraceMode.set(' + str(FreqTraceMode.get()) + ')\n')
1132  ConfgFile.write('SingleShotSA.set(' + str(SingleShotSA.get()) + ')\n')
1133  else:
1134  ConfgFile.write('DestroySpectrumScreen()\n')
1135  #
1136  if DacScreenStatus.get() > 0:
1137  ConfgFile.write('MakeDacScreen()\n')
1138  ConfgFile.write("win1.geometry('+" + str(win1.winfo_x()) + '+' + str(win1.winfo_y()) + "')\n")
1139  else:
1140  ConfgFile.write('DestroyDacScreen()\n')
1141  if DigScreenStatus.get() > 0:
1142  ConfgFile.write('MakeDigScreen()\n')
1143  ConfgFile.write("win2.geometry('+" + str(win2.winfo_x()) + '+' + str(win2.winfo_y()) + "')\n")
1144  else:
1145  ConfgFile.write('DestroyDigScreen()\n')
1146  if EnableHSsampling > 0:
1147  ConfgFile.write('FminEntry.delete(0,"end")\n')
1148  ConfgFile.write('FminEntry.insert(0, ' + FminEntry.get() + ')\n')
1149  ConfgFile.write('HtMulEntry.delete(0,"end")\n')
1150  ConfgFile.write('HtMulEntry.insert(0, ' + HtMulEntry.get() + ')\n')
1151  ConfgFile.write('Auto_ETS_Comp.set(' + str(Auto_ETS_Comp.get()) + ')\n')
1152  try:
1153  ConfgFile.write('ets_TC1Entry.delete(0,"end")\n')
1154  ConfgFile.write('ets_TC1Entry.insert(0, ' + ets_TC1Entry.get() + ')\n')
1155  ConfgFile.write('ETS_TC1.set(' + ets_TC1Entry.get() + ')\n')
1156  ConfgFile.write('ets_A1Entry.delete(0,"end")\n')
1157  ConfgFile.write('ets_A1Entry.insert(0, ' + ets_A1Entry.get() + ')\n')
1158  ConfgFile.write('ETS_A1.set(' + ets_A1Entry.get() + ')\n')
1159  ConfgFile.write('ets_TC2Entry.delete(0,"end")\n')
1160  ConfgFile.write('ets_TC2Entry.insert(0, ' + ets_TC2Entry.get() + ')\n')
1161  ConfgFile.write('ETS_TC2.set(' + ets_TC2Entry.get() + ')\n')
1162  ConfgFile.write('ets_A2Entry.delete(0,"end")\n')
1163  ConfgFile.write('ets_A2Entry.insert(0, ' + ets_A2Entry.get() + ')\n')
1164  ConfgFile.write('ETS_A2.set(' + ets_A2Entry.get() + ')\n')
1165  except:
1166  ConfgFile.write('ETS_TC1.set(' + str(ETS_TC1.get()) + ')\n')
1167  ConfgFile.write('ETS_A1.set(' + str(ETS_A1.get()) + ')\n')
1168  ConfgFile.write('ETS_TC2.set(' + str(ETS_TC2.get()) + ')\n')
1169  ConfgFile.write('ETS_A2.set(' + str(ETS_A2.get()) + ')\n')
1170  if DigFiltStatus.get() == 1:
1171  ConfgFile.write('MakeDigFiltWindow()\n')
1172  ConfgFile.write("digfltwindow.geometry('+" + str(digfltwindow.winfo_x()) + '+' + str(digfltwindow.winfo_y()) + "')\n")
1173  ConfgFile.write('DigFiltABoxCar.set(' + str(DigFiltABoxCar.get()) + ')\n')
1174  ConfgFile.write('DigFiltBBoxCar.set(' + str(DigFiltBBoxCar.get()) + ')\n')
1175  ConfgFile.write('BCALenEntry.delete(0,"end")\n')
1176  ConfgFile.write('BCALenEntry.insert(0, ' + BCALenEntry.get() + ')\n')
1177  ConfgFile.write('BCBLenEntry.delete(0,"end")\n')
1178  ConfgFile.write('BCBLenEntry.insert(0, ' + BCBLenEntry.get() + ')\n')
1179  ConfgFile.write('AWGALenEntry.delete(0,"end")\n')
1180  ConfgFile.write('AWGALenEntry.insert(0, ' + AWGALenEntry.get() + ')\n')
1181  ConfgFile.write('AWGFiltABoxCar.set(' + str(AWGFiltABoxCar.get()) + ')\n')
1182  ConfgFile.write('AWGBLenEntry.delete(0,"end")\n')
1183  ConfgFile.write('AWGBLenEntry.insert(0, ' + AWGBLenEntry.get() + ')\n')
1184  ConfgFile.write('AWGFiltBBoxCar.set(' + str(AWGFiltBBoxCar.get()) + ')\n')
1185  ConfgFile.write('BuildBoxCarA()\n')
1186  ConfgFile.write('BuildBoxCarB()\n')
1187  ConfgFile.write('BuildAWGBoxCarA()\n')
1188  ConfgFile.write('BuildAWGBoxCarB()\n')
1189  else:
1190  ConfgFile.write('DestroyDigFiltScreen()\n')
1191  if MinigenScreenStatus.get() == 1:
1192  ConfgFile.write('MakeMinigenWindow()\n')
1193  ConfgFile.write("minigenwindow.geometry('+" + str(minigenwindow.winfo_x()) + '+' + str(minigenwindow.winfo_y()) + "')\n")
1194  ConfgFile.write('MinigenMode.set(' + str(MinigenMode.get()) + ')\n')
1195  ConfgFile.write('MinigenFout.delete(0,END)\n')
1196  ConfgFile.write('MinigenFout.insert(4, ' + MinigenFout.get() + ')\n')
1197  ConfgFile.write('MinigenFclk.delete(0,END)\n')
1198  ConfgFile.write('MinigenFclk.insert(4, ' + MinigenFclk.get() + ')\n')
1199  ConfgFile.write('SCLKPort.set(' + str(SCLKPort.get()) + ')\n')
1200  ConfgFile.write('SDATAPort.set(' + str(SDATAPort.get()) + ')\n')
1201  ConfgFile.write('SLATCHPort.set(' + str(SLATCHPort.get()) + ')\n')
1202  else:
1203  ConfgFile.write('DestroyMinigenScreen()\n')
1204  if MuxScreenStatus.get() == 1:
1205  ConfgFile.write('MakeMuxModeWindow()\n')
1206  ConfgFile.write("muxwindow.geometry('+" + str(muxwindow.winfo_x()) + '+' + str(muxwindow.winfo_y()) + "')\n")
1207  ConfgFile.write('Show_CBA.set(' + str(Show_CBA.get()) + ')\n')
1208  ConfgFile.write('Show_CBB.set(' + str(Show_CBB.get()) + ')\n')
1209  ConfgFile.write('Show_CBC.set(' + str(Show_CBC.get()) + ')\n')
1210  ConfgFile.write('Show_CBD.set(' + str(Show_CBD.get()) + ')\n')
1211  ConfgFile.write('MuxEnb.set(' + str(MuxEnb.get()) + ')\n')
1212  ConfgFile.write('DualMuxMode.set(' + str(DualMuxMode.get()) + ')\n')
1213  ConfgFile.write('ChopMuxMode.set(' + str(ChopMuxMode.get()) + ')\n')
1214  ConfgFile.write('ChopTrig.set(' + str(ChopTrig.get()) + ')\n')
1215  ConfgFile.write('CHB_Asb.delete(0,END)\n')
1216  ConfgFile.write('CHB_Asb.insert(0, ' + CHB_Asb.get() + ')\n')
1217  ConfgFile.write('CHB_Bsb.delete(0,END)\n')
1218  ConfgFile.write('CHB_Bsb.insert(0, ' + CHB_Bsb.get() + ')\n')
1219  ConfgFile.write('CHB_Csb.delete(0,END)\n')
1220  ConfgFile.write('CHB_Csb.insert(0, ' + CHB_Csb.get() + ')\n')
1221  ConfgFile.write('CHB_Dsb.delete(0,END)\n')
1222  ConfgFile.write('CHB_Dsb.insert(0, ' + CHB_Dsb.get() + ')\n')
1223  ConfgFile.write('CHB_APosEntry.delete(0,END)\n')
1224  ConfgFile.write('CHB_APosEntry.insert(4, ' + CHB_APosEntry.get() + ')\n')
1225  ConfgFile.write('CHB_BPosEntry.delete(0,END)\n')
1226  ConfgFile.write('CHB_BPosEntry.insert(4, ' + CHB_BPosEntry.get() + ')\n')
1227  ConfgFile.write('CHB_CPosEntry.delete(0,END)\n')
1228  ConfgFile.write('CHB_CPosEntry.insert(4, ' + CHB_CPosEntry.get() + ')\n')
1229  ConfgFile.write('CHB_DPosEntry.delete(0,END)\n')
1230  ConfgFile.write('CHB_DPosEntry.insert(4, ' + CHB_DPosEntry.get() + ')\n')
1231  else:
1232  ConfgFile.write('DestroyMuxScreen()\n')
1233  # Save Phase Anayzer stuff after Analog Mux in case they are both open
1234  if PhAScreenStatus.get() > 0:
1235  ConfgFile.write('GRWPhA = ' + str(GRWPhA) + '\n')
1236  ConfgFile.write('GRHPhA = ' + str(GRHPhA) + '\n')
1237  ConfgFile.write('MakePhAWindow()\n')
1238  ConfgFile.write("phawindow.geometry('+" + str(phawindow.winfo_x()) + '+' + str(phawindow.winfo_y()) + "')\n")
1239  ConfgFile.write('VScale.delete(0,END)\n')
1240  ConfgFile.write('VScale.insert(0, ' + str(VScale.get()) + ')\n')
1241  ConfgFile.write('IScale.delete(0,END)\n')
1242  ConfgFile.write('IScale.insert(0, ' + str(IScale.get()) + ')\n')
1243  ConfgFile.write('RefphEntry.delete(0,END)\n')
1244  ConfgFile.write('RefphEntry.insert(0, "' + str(RefphEntry.get()) + '")\n')
1245  if vat_btn.config('text')[-1] == 'OFF':
1246  ConfgFile.write('vat_btn.config(text="OFF", style="Stop.TButton")\n')
1247  else:
1248  ConfgFile.write('vat_btn.config(text="ON", style="Run.TButton")\n')
1249  if MuxScreenStatus.get() == 0: # these buttons do not exist if Mux screen open
1250  if vbt_btn.config('text')[-1] == 'OFF':
1251  ConfgFile.write('vbt_btn.config(text="OFF", style="Stop.TButton")\n')
1252  else:
1253  ConfgFile.write('vbt_btn.config(text="ON", style="Run.TButton")\n')
1254  if vabt_btn.config('text')[-1] == 'OFF':
1255  ConfgFile.write('vabt_btn.config(text="OFF", style="Stop.TButton")\n')
1256  else:
1257  ConfgFile.write('vabt_btn.config(text="ON", style="Run.TButton")\n')
1258  else: # But these do
1259  ConfgFile.write('ShowPB_A.set(' + str(ShowPB_A.get()) + ')\n')
1260  ConfgFile.write('ShowPB_B.set(' + str(ShowPB_B.get()) + ')\n')
1261  ConfgFile.write('ShowPB_C.set(' + str(ShowPB_C.get()) + ')\n')
1262  ConfgFile.write('ShowPB_D.set(' + str(ShowPB_D.get()) + ')\n')
1263  if iat_btn.config('text')[-1] == 'OFF':
1264  ConfgFile.write('iat_btn.config(text="OFF", style="Stop.TButton")\n')
1265  else:
1266  ConfgFile.write('iat_btn.config(text="ON", style="Run.TButton")\n')
1267  if ibt_btn.config('text')[-1] == 'OFF':
1268  ConfgFile.write('ibt_btn.config(text="OFF", style="Stop.TButton")\n')
1269  else:
1270  ConfgFile.write('ibt_btn.config(text="ON", style="Run.TButton")\n')
1271  if iapbt_btn.config('text')[-1] == 'OFF':
1272  ConfgFile.write('iapbt_btn.config(text="OFF", style="Stop.TButton")\n')
1273  else:
1274  ConfgFile.write('iapbt_btn.config(text="ON", style="Run.TButton")\n')
1275  #
1276  else:
1277  ConfgFile.write('DestroyPhAScreen()\n')
1278  if BodeScreenStatus.get() == 1:
1279  ConfgFile.write('GRWBP = ' + str(GRWBP) + '\n')
1280  ConfgFile.write('GRHBP = ' + str(GRHBP) + '\n')
1281  ConfgFile.write('RelPhaseCenter.set(' + str(RelPhaseCenter.get()) + ')\n')
1282  ConfgFile.write('ImpedanceCenter.set(' + str(ImpedanceCenter.get()) + ')\n')
1283  ConfgFile.write('MakeBodeWindow()\n')
1284  ConfgFile.write("bodewindow.geometry('+" + str(bodewindow.winfo_x()) + '+' + str(bodewindow.winfo_y()) + "')\n")
1285  ConfgFile.write('ShowCA_VdB.set(' + str(ShowCA_VdB.get()) + ')\n')
1286  ConfgFile.write('ShowCB_VdB.set(' + str(ShowCB_VdB.get()) + ')\n')
1287  ConfgFile.write('ShowCA_P.set(' + str(ShowCA_P.get()) + ')\n')
1288  ConfgFile.write('ShowCB_P.set(' + str(ShowCB_P.get()) + ')\n')
1289  ConfgFile.write('ShowCA_RdB.set(' + str(ShowCA_RdB.get()) + ')\n')
1290  ConfgFile.write('ShowCA_RP.set(' + str(ShowCA_RP.get()) + ')\n')
1291  ConfgFile.write('ShowCB_RdB.set(' + str(ShowCB_RdB.get()) + ')\n')
1292  ConfgFile.write('ShowCB_RP.set(' + str(ShowCB_RP.get()) + ')\n')
1293  ConfgFile.write('BodeDisp.set(' + str(BodeDisp.get()) + ')\n')
1294  ConfgFile.write('ShowMarkerBP.set(' + str(ShowMarkerBP.get()) + ')\n')
1295  ConfgFile.write('ShowMathBP.set(' + str(ShowMathBP.get()) + ')\n')
1296  ConfgFile.write('ShowRMathBP.set(' + str(ShowRMathBP.get()) + ')\n')
1297  ConfgFile.write('HScaleBP.set(' + str(HScaleBP.get()) + ')\n')
1298  ConfgFile.write('NSteps.set(' + str(NSteps.get()) + ')\n')
1299  ConfgFile.write('DBdivindexBP.set(' + str(DBdivindexBP.get()) + ')\n')
1300  ConfgFile.write('DBlevelBP.set(' + str(DBlevelBP.get()) + ')\n')
1301  ConfgFile.write('FSweepMode.set(' + str(FSweepMode.get()) + ')\n')
1302  ConfgFile.write('SweepStepBodeEntry.delete(0,END)\n')
1303  ConfgFile.write('SweepStepBodeEntry.insert(4, ' + SweepStepBodeEntry.get() + ')\n')
1304  ConfgFile.write('StopBodeEntry.delete(0,END)\n')
1305  ConfgFile.write('StopBodeEntry.insert(4, ' + StopBodeEntry.get() + ')\n')
1306  ConfgFile.write('StartBodeEntry.delete(0,END)\n')
1307  ConfgFile.write('StartBodeEntry.insert(4, ' + StartBodeEntry.get() + ')\n')
1308  ConfgFile.write('Show_Rseries.set(' + str(Show_Rseries.get()) + ')\n')
1309  ConfgFile.write('Show_Xseries.set(' + str(Show_Xseries.get()) + ')\n')
1310  ConfgFile.write('Show_Magnitude.set(' + str(Show_Magnitude.get()) + ')\n')
1311  ConfgFile.write('Show_Angle.set(' + str(Show_Angle.get()) + ')\n')
1312  else:
1313  ConfgFile.write('DestroyBodeScreen()\n')
1314  if MeasureStatus.get() == 1:
1315  # Save strings
1316  ConfgFile.write('ChaLableSrring1 = "' + ChaLableSrring1 + '"\n')
1317  ConfgFile.write('ChaLableSrring2 = "' + ChaLableSrring2 + '"\n')
1318  ConfgFile.write('ChaLableSrring3 = "' + ChaLableSrring3 + '"\n')
1319  ConfgFile.write('ChaLableSrring4 = "' + ChaLableSrring4 + '"\n')
1320  ConfgFile.write('ChaLableSrring5 = "' + ChaLableSrring5 + '"\n')
1321  ConfgFile.write('ChaLableSrring6 = "' + ChaLableSrring6 + '"\n')
1322  ConfgFile.write('ChbLableSrring1 = "' + ChbLableSrring1 + '"\n')
1323  ConfgFile.write('ChbLableSrring2 = "' + ChbLableSrring2 + '"\n')
1324  ConfgFile.write('ChbLableSrring3 = "' + ChbLableSrring3 + '"\n')
1325  ConfgFile.write('ChbLableSrring4 = "' + ChbLableSrring4 + '"\n')
1326  ConfgFile.write('ChbLableSrring5 = "' + ChbLableSrring5 + '"\n')
1327  ConfgFile.write('ChbLableSrring6 = "' + ChbLableSrring6 + '"\n')
1328  ConfgFile.write('ChaMeasString1 = "' + ChaMeasString1 + '"\n')
1329  ConfgFile.write('ChaMeasString2 = "' + ChaMeasString2 + '"\n')
1330  ConfgFile.write('ChaMeasString3 = "' + ChaMeasString3 + '"\n')
1331  ConfgFile.write('ChaMeasString4 = "' + ChaMeasString4 + '"\n')
1332  ConfgFile.write('ChaMeasString5 = "' + ChaMeasString5 + '"\n')
1333  ConfgFile.write('ChaMeasString6 = "' + ChaMeasString6 + '"\n')
1334  ConfgFile.write('ChbMeasString1 = "' + ChbMeasString1 + '"\n')
1335  ConfgFile.write('ChbMeasString2 = "' + ChbMeasString2 + '"\n')
1336  ConfgFile.write('ChbMeasString3 = "' + ChbMeasString3 + '"\n')
1337  ConfgFile.write('ChbMeasString4 = "' + ChbMeasString4 + '"\n')
1338  ConfgFile.write('ChbMeasString5 = "' + ChbMeasString5 + '"\n')
1339  ConfgFile.write('ChbMeasString6 = "' + ChbMeasString6 + '"\n')
1340  ConfgFile.write('MakeMeasureScreen()\n')
1341  ConfgFile.write("measurewindow.geometry('+" + str(measurewindow.winfo_x()) + '+' + str(measurewindow.winfo_y()) + "')\n")
1342  else:
1343  ConfgFile.write('DestroyMeasuewScreen()\n')
1344  if ETSStatus.get() == 1: #
1345  ConfgFile.write('MakeETSWindow()\n')
1346  ConfgFile.write("etswindow.geometry('+" + str(etswindow.winfo_x()) + '+' + str(etswindow.winfo_y()) + "')\n")
1347  ConfgFile.write('ETSDisp.set(' + str(ETSDisp.get()) + ')\n')
1348  ConfgFile.write('ETSDir.set(' + str(ETSDir.get()) + ')\n')
1349  ConfgFile.write('FMulXEntry.delete(0,END)\n')
1350  ConfgFile.write('FMulXEntry.insert(6, ' + FMulXEntry.get() + ')\n')
1351  ConfgFile.write('DivXEntry.delete(0,END)\n')
1352  ConfgFile.write('DivXEntry.insert(4, ' + DivXEntry.get() + ')\n')
1353  ConfgFile.write('ETSts.delete(0,END)\n')
1354  ConfgFile.write('ETSts.insert(4, ' + ETSts.get() + ')\n')
1355  else:
1356  ConfgFile.write('DestroyETSScreen()\n')
1357  #
1358  ConfgFile.write('TRIGGERentry.delete(0,END)\n')
1359  ConfgFile.write('TRIGGERentry.insert(4, ' + TRIGGERentry.get() + ')\n')
1360  ConfgFile.write('HoldOffentry.delete(0,"end")\n')
1361  ConfgFile.write('HoldOffentry.insert(0, ' + HoldOffentry.get() + ')\n')
1362  ConfgFile.write('HozPossentry.delete(0,"end")\n')
1363  ConfgFile.write('HozPossentry.insert(0, ' + HozPossentry.get() + ')\n')
1364  ConfgFile.write('TMsb.delete(0,END)\n')
1365  ConfgFile.write('TMsb.insert(0, ' + TMsb.get() + ')\n')
1366  ConfgFile.write('TgInput.set(' + str(TgInput.get()) + ')\n')
1367  ConfgFile.write('AutoLevel.set(' + str(AutoLevel.get()) + ')\n')
1368  ConfgFile.write('ManualTrigger.set(' + str(ManualTrigger.get()) + ')\n')
1369  ConfgFile.write('SingleShot.set(' + str(SingleShot.get()) + ')\n')
1370  ConfgFile.write('TgEdge.set(' + str(TgEdge.get()) + ')\n')
1371  ConfgFile.write('Roll_Mode.set(' + str(Roll_Mode.get()) + ')\n')
1372  ConfgFile.write('Xsignal.set(' + str(Xsignal.get()) + ')\n')
1373  ConfgFile.write('YsignalVA.set(' + str(YsignalVA.get()) + ')\n')
1374  ConfgFile.write('YsignalIA.set(' + str(YsignalIA.get()) + ')\n')
1375  ConfgFile.write('YsignalVB.set(' + str(YsignalVB.get()) + ')\n')
1376  ConfgFile.write('YsignalIB.set(' + str(YsignalIB.get()) + ')\n')
1377  ConfgFile.write('YsignalM.set(' + str(YsignalM.get()) + ')\n')
1378  ConfgFile.write('YsignalMX.set(' + str(YsignalMX.get()) + ')\n')
1379  ConfgFile.write('YsignalMY.set(' + str(YsignalMY.get()) + ')\n')
1380  #
1381  ConfgFile.write('TimeDisp.set(' + str(TimeDisp.get()) + ')\n')
1382  ConfgFile.write('XYDisp.set(' + str(XYDisp.get()) + ')\n')
1383  ConfgFile.write('FreqDisp.set(' + str(FreqDisp.get()) + ')\n')
1384  ConfgFile.write('IADisp.set(' + str(IADisp.get()) + ')\n')
1385  ConfgFile.write('ShowC1_V.set(' + str(ShowC1_V.get()) + ')\n')
1386  ConfgFile.write('ShowC1_I.set(' + str(ShowC1_I.get()) + ')\n')
1387  ConfgFile.write('ShowC2_V.set(' + str(ShowC2_V.get()) + ')\n')
1388  ConfgFile.write('ShowC2_I.set(' + str(ShowC2_I.get()) + ')\n')
1389  ConfgFile.write('Show_MathX.set(' + str(Show_MathX.get()) + ')\n')
1390  ConfgFile.write('Show_MathY.set(' + str(Show_MathY.get()) + ')\n')
1391  ConfgFile.write('AutoCenterA.set(' + str(AutoCenterA.get()) + ')\n')
1392  ConfgFile.write('AutoCenterB.set(' + str(AutoCenterB.get()) + ')\n')
1393  ConfgFile.write('TRACEmodeTime.set(' + str(TRACEmodeTime.get()) + ')\n')
1394  #
1395  ConfgFile.write('CHAVPosEntry.delete(0,END)\n')
1396  ConfgFile.write('CHAVPosEntry.insert(4, ' + CHAVPosEntry.get() + ')\n')
1397  ConfgFile.write('CHAIPosEntry.delete(0,END)\n')
1398  ConfgFile.write('CHAIPosEntry.insert(4, ' + CHAIPosEntry.get() + ')\n')
1399  ConfgFile.write('CHAsb.delete(0,END)\n')
1400  ConfgFile.write('CHAsb.insert(0, ' + CHAsb.get() + ')\n')
1401  ConfgFile.write('CHAIsb.delete(0,END)\n')
1402  ConfgFile.write('CHAIsb.insert(0, ' + CHAIsb.get() + ')\n')
1403  #
1404  ConfgFile.write('CHBVPosEntry.delete(0,END)\n')
1405  ConfgFile.write('CHBVPosEntry.insert(4, ' + CHBVPosEntry.get() + ')\n')
1406  ConfgFile.write('CHBIPosEntry.delete(0,END)\n')
1407  ConfgFile.write('CHBIPosEntry.insert(4, ' + CHBIPosEntry.get() + ')\n')
1408  ConfgFile.write('CHBsb.delete(0,END)\n')
1409  ConfgFile.write('CHBsb.insert(0, ' + CHBsb.get() + ')\n')
1410  ConfgFile.write('CHBIsb.delete(0,END)\n')
1411  ConfgFile.write('CHBIsb.insert(0, ' + CHBIsb.get() + ')\n')
1412  # AWG stuff
1413  ConfgFile.write('AWG_Amp_Mode.set('+ str(AWG_Amp_Mode.get()) + ')\n')
1414  ConfgFile.write('AWGAMode.set('+ str(AWGAMode.get()) + ')\n')
1415  ConfgFile.write('AWGAIOMode.set('+ str(AWGAIOMode.get()) + ')\n')
1416  ConfgFile.write('AWGATerm.set('+ str(AWGATerm.get()) + ')\n')
1417  ConfgFile.write('AWGAPhaseDelay.set('+ str(AWGAPhaseDelay.get()) + ')\n')
1418  ConfgFile.write('AWGAAmplEntry.delete(0,END)\n')
1419  ConfgFile.write('AWGAAmplEntry.insert(4, ' + AWGAAmplEntry.get() + ')\n')
1420  ConfgFile.write('AWGAOffsetEntry.delete(0,END)\n')
1421  ConfgFile.write('AWGAOffsetEntry.insert(4, ' + AWGAOffsetEntry.get() + ')\n')
1422  ConfgFile.write('AWGAFreqEntry.delete(0,END)\n')
1423  ConfgFile.write('AWGAFreqEntry.insert(4, ' + AWGAFreqEntry.get() + ')\n')
1424  ConfgFile.write('AWGAPhaseEntry.delete(0,END)\n')
1425  ConfgFile.write('AWGAPhaseEntry.insert(4, ' + AWGAPhaseEntry.get() + ')\n')
1426  ConfgFile.write('AWGADutyCycleEntry.delete(0,END)\n')
1427  ConfgFile.write('AWGADutyCycleEntry.insert(4, ' + AWGADutyCycleEntry.get() + ')\n')
1428  ConfgFile.write('AWGAShape.set(' + str(AWGAShape.get()) + ')\n')
1429  ConfgFile.write('AWGARepeatFlag.set(' + str(AWGARepeatFlag.get()) + ')\n')
1430  ConfgFile.write('AWGABurstFlag.set(' + str(AWGABurstFlag.get()) + ')\n')
1431  ConfgFile.write('global AWGACycles; AWGACycles = ' + str(AWGACycles) + '\n')
1432  ConfgFile.write('global AWGABurstDelay; AWGABurstDelay = ' + str(AWGABurstDelay) + '\n')
1433  #
1434  ConfgFile.write('AWGBMode.set('+ str(AWGBMode.get()) + ')\n')
1435  ConfgFile.write('AWGBIOMode.set('+ str(AWGBIOMode.get()) + ')\n')
1436  ConfgFile.write('AWGBTerm.set('+ str(AWGBTerm.get()) + ')\n')
1437  ConfgFile.write('AWGBPhaseDelay.set('+ str(AWGBPhaseDelay.get()) + ')\n')
1438  ConfgFile.write('AWGBAmplEntry.delete(0,END)\n')
1439  ConfgFile.write('AWGBAmplEntry.insert(4, ' + AWGBAmplEntry.get() + ')\n')
1440  ConfgFile.write('AWGBOffsetEntry.delete(0,END)\n')
1441  ConfgFile.write('AWGBOffsetEntry.insert(4, ' + AWGBOffsetEntry.get() + ')\n')
1442  ConfgFile.write('AWGBFreqEntry.delete(0,END)\n')
1443  ConfgFile.write('AWGBFreqEntry.insert(4, ' + AWGBFreqEntry.get() + ')\n')
1444  ConfgFile.write('AWGBPhaseEntry.delete(0,END)\n')
1445  ConfgFile.write('AWGBPhaseEntry.insert(4, ' + AWGBPhaseEntry.get() + ')\n')
1446  ConfgFile.write('AWGBDutyCycleEntry.delete(0,END)\n')
1447  ConfgFile.write('AWGBDutyCycleEntry.insert(4, ' + AWGBDutyCycleEntry.get() + ')\n')
1448  ConfgFile.write('AWGBShape.set(' + str(AWGBShape.get()) + ')\n')
1449  ConfgFile.write('AWGBRepeatFlag.set(' + str(AWGBRepeatFlag.get()) + ')\n')
1450  ConfgFile.write('AWGBBurstFlag.set(' + str(AWGBBurstFlag.get()) + ')\n')
1451  ConfgFile.write('global AWGBCycles; AWGBCycles = ' + str(AWGBCycles) + '\n')
1452  ConfgFile.write('global AWGBBurstDelay; AWGBBurstDelay = ' + str(AWGBBurstDelay) + '\n')
1453  #
1454  ConfgFile.write('AWGSync.set(' + str(AWGSync.get()) + ')\n')
1455  ConfgFile.write('AWGAMathString = "' + AWGAMathString + '"\n')
1456  ConfgFile.write('AWGBMathString = "' + AWGBMathString + '"\n')
1457  ConfgFile.write('AWGAcsvFile = "' + AWGAcsvFile + '"\n')
1458  ConfgFile.write('AWGBcsvFile = "' + AWGBcsvFile + '"\n')
1459  ConfgFile.write('AWGAwavFile = "' + AWGAwavFile + '"\n')
1460  ConfgFile.write('AWGBwavFile = "' + AWGBwavFile + '"\n')
1461  #
1462  if EnableScopeOnly == 0:
1463  ConfgFile.write('AWGANoiseEntry.delete(0,END)\n')
1464  ConfgFile.write('AWGANoiseEntry.insert(4, ' + AWGBNoiseEntry.get() + ')\n')
1465  ConfgFile.write('AWGBNoiseEntry.delete(0,END)\n')
1466  ConfgFile.write('AWGBNoiseEntry.insert(4, ' + AWGBNoiseEntry.get() + ')\n')
1467  ConfgFile.write('AWGAsbnoise.delete(0,END)\n')
1468  ConfgFile.write('AWGAsbnoise.insert(4, "'+ str(AWGAsbnoise.get()) + '")\n')
1469  ConfgFile.write('AWGBsbnoise.delete(0,END)\n')
1470  ConfgFile.write('AWGBsbnoise.insert(4, "' + str(AWGBsbnoise.get()) + '")\n')
1471  #
1472  ConfgFile.write('CHAVGainEntry.delete(0,END)\n')
1473  ConfgFile.write('CHAVGainEntry.insert(4, ' + CHAVGainEntry.get() + ')\n')
1474  ConfgFile.write('CHBVGainEntry.delete(0,END)\n')
1475  ConfgFile.write('CHBVGainEntry.insert(4, ' + CHBVGainEntry.get() + ')\n')
1476  ConfgFile.write('CHAVOffsetEntry.delete(0,END)\n')
1477  ConfgFile.write('CHAVOffsetEntry.insert(4, ' + CHAVOffsetEntry.get() + ')\n')
1478  ConfgFile.write('CHBVOffsetEntry.delete(0,END)\n')
1479  ConfgFile.write('CHBVOffsetEntry.insert(4, ' + CHBVOffsetEntry.get() + ')\n')
1480  #
1481  ConfgFile.write('MeasDCV1.set(' + str(MeasDCV1.get()) + ')\n')
1482  ConfgFile.write('MeasMinV1.set(' + str(MeasMinV1.get()) + ')\n')
1483  ConfgFile.write('MeasMaxV1.set(' + str(MeasMaxV1.get()) + ')\n')
1484  ConfgFile.write('MeasBaseV1.set(' + str(MeasBaseV1.get()) + ')\n')
1485  ConfgFile.write('MeasTopV1.set(' + str(MeasTopV1.get()) + ')\n')
1486  ConfgFile.write('MeasMidV1.set(' + str(MeasMidV1.get()) + ')\n')
1487  ConfgFile.write('MeasPPV1.set(' + str(MeasPPV1.get()) + ')\n')
1488  ConfgFile.write('MeasRMSV1.set(' + str(MeasRMSV1.get()) + ')\n')
1489  ConfgFile.write('MeasDCI1.set(' + str(MeasDCI1.get()) + ')\n')
1490  ConfgFile.write('MeasMinI1.set(' + str(MeasMinI1.get()) + ')\n')
1491  ConfgFile.write('MeasMaxI1.set(' + str(MeasMaxI1.get()) + ')\n')
1492  ConfgFile.write('MeasMidI1.set(' + str(MeasMidI1.get()) + ')\n')
1493  ConfgFile.write('MeasPPI1.set(' + str(MeasPPI1.get()) + ')\n')
1494  ConfgFile.write('MeasRMSI1.set(' + str(MeasRMSI1.get()) + ')\n')
1495  ConfgFile.write('MeasDiffAB.set(' + str(MeasDiffAB.get()) + ')\n')
1496  ConfgFile.write('MeasDCV2.set(' + str(MeasDCV2.get()) + ')\n')
1497  ConfgFile.write('MeasMinV2.set(' + str(MeasMinV2.get()) + ')\n')
1498  ConfgFile.write('MeasMaxV2.set(' + str(MeasMaxV2.get()) + ')\n')
1499  ConfgFile.write('MeasBaseV2.set(' + str(MeasBaseV2.get()) + ')\n')
1500  ConfgFile.write('MeasTopV2.set(' + str(MeasTopV2.get()) + ')\n')
1501  ConfgFile.write('MeasMidV2.set(' + str(MeasMidV2.get()) + ')\n')
1502  ConfgFile.write('MeasPPV2.set(' + str(MeasPPV2.get()) + ')\n')
1503  ConfgFile.write('MeasRMSV2.set(' + str(MeasRMSV2.get()) + ')\n')
1504  ConfgFile.write('MeasDCI2.set(' + str(MeasDCI2.get()) + ')\n')
1505  ConfgFile.write('MeasMinI2.set(' + str(MeasMinI2.get()) + ')\n')
1506  ConfgFile.write('MeasMaxI2.set(' + str(MeasMaxI2.get()) + ')\n')
1507  ConfgFile.write('MeasMidI2.set(' + str(MeasMidI2.get()) + ')\n')
1508  ConfgFile.write('MeasPPI2.set(' + str(MeasPPI2.get()) + ')\n')
1509  ConfgFile.write('MeasRMSI2.set(' + str(MeasRMSI2.get()) + ')\n')
1510  ConfgFile.write('MeasDiffBA.set(' + str(MeasDiffBA.get()) + ')\n')
1511  #
1512  ConfgFile.write('MeasAHW.set(' + str(MeasAHW.get()) + ')\n')
1513  ConfgFile.write('MeasALW.set(' + str(MeasALW.get()) + ')\n')
1514  ConfgFile.write('MeasADCy.set(' + str(MeasADCy.get()) + ')\n')
1515  ConfgFile.write('MeasAPER.set(' + str(MeasAPER.get()) + ')\n')
1516  ConfgFile.write('MeasAFREQ.set(' + str(MeasAFREQ.get()) + ')\n')
1517  ConfgFile.write('MeasBHW.set(' + str(MeasBHW.get()) + ')\n')
1518  ConfgFile.write('MeasBLW.set(' + str(MeasBLW.get()) + ')\n')
1519  ConfgFile.write('MeasBDCy.set(' + str(MeasBDCy.get()) + ')\n')
1520  ConfgFile.write('MeasBPER.set(' + str(MeasBPER.get()) + ')\n')
1521  ConfgFile.write('MeasBFREQ.set(' + str(MeasBFREQ.get()) + ')\n')
1522  ConfgFile.write('MeasPhase.set(' + str(MeasPhase.get()) + ')\n')
1523  ConfgFile.write('MeasDelay.set(' + str(MeasDelay.get()) + ')\n')
1524  #
1525  ConfgFile.write('MathTrace.set(' + str(MathTrace.get()) + ')\n')
1526  #
1527  ConfgFile.write('CHAIGainEntry.delete(0,END)\n')
1528  ConfgFile.write('CHAIGainEntry.insert(4, ' + CHAIGainEntry.get() + ')\n')
1529  ConfgFile.write('CHBIGainEntry.delete(0,END)\n')
1530  ConfgFile.write('CHBIGainEntry.insert(4, ' + CHBIGainEntry.get() + ')\n')
1531  ConfgFile.write('CHAIOffsetEntry.delete(0,END)\n')
1532  ConfgFile.write('CHAIOffsetEntry.insert(4, ' + CHAIOffsetEntry.get() + ')\n')
1533  ConfgFile.write('CHBIOffsetEntry.delete(0,END)\n')
1534  ConfgFile.write('CHBIOffsetEntry.insert(4, ' + CHBIOffsetEntry.get() + ')\n')
1535  # Save strings
1536  ConfgFile.write('UserAString = "' + UserAString + '"\n')
1537  ConfgFile.write('UserALabel = "' + UserALabel + '"\n')
1538  ConfgFile.write('UserBString = "' + UserBString + '"\n')
1539  ConfgFile.write('UserBLabel = "' + UserBLabel + '"\n')
1540  ConfgFile.write('FFTUserWindowString= "' + FFTUserWindowString + '"\n')
1541  ConfgFile.write('DigFilterAString = "' + DigFilterAString + '"\n')
1542  ConfgFile.write('DigFilterBString = "' + DigFilterBString + '"\n')
1543  # save channel AC frequency compensation settings
1544  try:
1545  CHA_TC1.set(float(cha_TC1Entry.get()))
1546  CHA_TC2.set(float(cha_TC2Entry.get()))
1547  CHB_TC1.set(float(chb_TC1Entry.get()))
1548  CHB_TC2.set(float(chb_TC2Entry.get()))
1549  CHA_A1.set(float(cha_A1Entry.get()))
1550  CHA_A2.set(float(cha_A2Entry.get()))
1551  CHB_A1.set(float(chb_A1Entry.get()))
1552  CHB_A2.set(float(chb_A2Entry.get()))
1553  except:
1554  donothing()
1555  ConfgFile.write('CHA_RC_HP.set(' + str(CHA_RC_HP.get()) + ')\n')
1556  ConfgFile.write('CHB_RC_HP.set(' + str(CHB_RC_HP.get()) + ')\n')
1557  ConfgFile.write('CHAI_RC_HP.set(' + str(CHAI_RC_HP.get()) + ')\n')
1558  ConfgFile.write('CHBI_RC_HP.set(' + str(CHBI_RC_HP.get()) + ')\n')
1559  ConfgFile.write('CHA_TC1.set(' + str(CHA_TC1.get()) + ')\n')
1560  ConfgFile.write('CHA_TC2.set(' + str(CHA_TC2.get()) + ')\n')
1561  ConfgFile.write('CHB_TC1.set(' + str(CHB_TC1.get()) + ')\n')
1562  ConfgFile.write('CHB_TC2.set(' + str(CHB_TC2.get()) + ')\n')
1563  ConfgFile.write('CHA_A1.set(' + str(CHA_A1.get()) + ')\n')
1564  ConfgFile.write('CHA_A2.set(' + str(CHA_A2.get()) + ')\n')
1565  ConfgFile.write('CHB_A1.set(' + str(CHB_A1.get()) + ')\n')
1566  ConfgFile.write('CHB_A2.set(' + str(CHB_A2.get()) + ')\n')
1567  ConfgFile.write('cha_TC1Entry.delete(0,END)\n')
1568  ConfgFile.write('cha_TC1Entry.insert(4, ' + str(CHA_TC1.get()) + ')\n')
1569  ConfgFile.write('cha_TC2Entry.delete(0,END)\n')
1570  ConfgFile.write('cha_TC2Entry.insert(4, ' + str(CHA_TC2.get()) + ')\n')
1571  ConfgFile.write('chb_TC1Entry.delete(0,END)\n')
1572  ConfgFile.write('chb_TC1Entry.insert(4, ' + str(CHB_TC1.get()) + ')\n')
1573  ConfgFile.write('chb_TC2Entry.delete(0,END)\n')
1574  ConfgFile.write('chb_TC2Entry.insert(4, ' + str(CHB_TC2.get()) + ')\n')
1575  ConfgFile.write('cha_A1Entry.delete(0,END)\n')
1576  ConfgFile.write('cha_A1Entry.insert(4, ' + str(CHA_A1.get()) + ')\n')
1577  ConfgFile.write('cha_A2Entry.delete(0,END)\n')
1578  ConfgFile.write('cha_A2Entry.insert(4, ' + str(CHA_A2.get()) + ')\n')
1579  ConfgFile.write('chb_A1Entry.delete(0,END)\n')
1580  ConfgFile.write('chb_A1Entry.insert(4, ' + str(CHB_A1.get()) + ')\n')
1581  ConfgFile.write('chb_A2Entry.delete(0,END)\n')
1582  ConfgFile.write('chb_A2Entry.insert(4, ' + str(CHB_A2.get()) + ')\n')
1583 
1584  # extra Spectrum stuff
1585  if SpectrumScreenStatus.get() > 0 or IAScreenStatus.get() > 0 or BodeScreenStatus.get() > 0:
1586  ConfgFile.write('SMPfftpwrTwo.set(' + str(SMPfftpwrTwo.get()) + ')\n')
1587  ConfgFile.write('FFTwindow.set(' + str(FFTwindow.get()) + ')\n')
1588  ConfgFile.write('ZEROstuffing.set(' + str(ZEROstuffing.get()) + ')\n')
1589  ConfgFile.write('Vdiv.set(' + str(Vdiv.get()) + ')\n')
1590  #
1591  ConfgFile.write('DBdivindex.set(' + str(DBdivindex.get()) + ')\n')
1592  ConfgFile.write('DBlevel.set(' + str(DBlevel.get()) + ')\n')
1593  # ConfgFile.write('TRACEaverage.set(' + str(TRACEaverage.get()) + ')\n')
1594  ConfgFile.write('CutDC.set(' + str(CutDC.get()) + ')\n')
1595  #
1596  ConfgFile.close()
1597 
1598 def BSaveConfigIA():
1599  global iawindow
1600 
1601  filename = asksaveasfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=iawindow)
1602  BSaveConfig(filename)
1603 
1604 def BSaveConfigSA():
1605  global freqwindow
1606 
1607  filename = asksaveasfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=freqwindow)
1608  BSaveConfig(filename)
1609 
1610 def BSaveConfigBP():
1611  global bodewindow
1612 
1613  filename = asksaveasfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=bodewindow)
1614  BSaveConfig(filename)
1615 
1616 def BSaveConfigTime():
1617  global root
1618  filename = asksaveasfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=root)
1619  BSaveConfig(filename)
1620 
1621 def BLoadConfig(filename):
1622  global TgInput, TgEdge, SingleShot, AutoLevel, SingleShotSA, ManualTrigger
1623  global root, freqwindow, awgwindow, iawindow, xywindow, win1, win2
1624  global TRIGGERentry, TMsb, Xsignal, AutoCenterA, AutoCenterB
1625  global YsignalVA, YsignalIA, YsignalVB, YsignalIB, YsignalM, YsignalMX, YsignalMY
1626  global CHAsb, CHAIsb, CHBsb, CHBIsb, HScale, FreqTraceMode
1627  global CHAsbxy, CHAIsbxy, CHBsbxy, CHBIsbxy, HoldOffentry
1628  global CHAVPosEntryxy, CHBVPosEntryxy, CHAIPosEntryxy, CHBIPosEntryxy
1629  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, MathTrace, MathXUnits, MathYUnits
1630  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry, HozPossentry
1631  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGADutyCycleEntry
1632  global AWGAPhaseEntry, AWGAShape, AWGATerm, AWGAMode, AWGARepeatFlag, AWGBRepeatFlag
1633  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBDutyCycleEntry
1634  global AWGBPhaseEntry, AWGBShape, AWGBTerm, AWGBMode, AWGSync, AWGAIOMode, AWGBIOMode
1635  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
1636  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1, MeasDCI1, MeasMinI1
1637  global MeasMaxI1, MeasMidI1, MeasPPI1, MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2
1638  global MeasPPV2, MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2, MeasDiffAB, MeasDiffBA
1639  global MeasRMSV1, MeasRMSV2, MeasRMSI1, MeasRMSI2, MeasPhase, MeasDelay
1640  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ, IASource, DisplaySeries
1641  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
1642  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
1643  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, CutDC, AWG_Amp_Mode
1644  global FFTwindow, DBdivindex, DBlevel, TRACEmodeTime, TRACEaverage, Vdiv
1645  global SMPfftpwrTwo, SMPfft, StartFreqEntry, StopFreqEntry, ZEROstuffing
1646  global TimeDisp, XYDisp, FreqDisp, IADisp, AWGAPhaseDelay, AWGBPhaseDelay
1647  global RsystemEntry, ResScale, GainCorEntry, PhaseCorEntry
1648  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2
1649  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxScreenStatus, MuxEnb
1650  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry, muxwindow, ChopMuxMode, ChopTrig, DualMuxMode
1651  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
1652  global MathString, MathXString, MathYString, UserAString, UserALabel, UserBString, UserBLabel
1653  global MathAxis, MathXAxis, MathYAxis, Show_MathX, Show_MathY, MathScreenStatus, MathWindow
1654  global AWGAMathString, AWGBMathString, FFTUserWindowString, DigFilterAString, DigFilterBString
1655  global GRWF, GRHF, GRWBP, GRHBP, GRWXY, GRHXY, GRWIA, GRHIA, MeasureStatus
1656  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
1657  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
1658  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
1659  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
1660  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2, CHAI_RC_HP, CHBI_RC_HP
1661  global CHA_A1, CHA_A2, CHB_A1, CHB_A2, RelPhaseCenter, ImpedanceCenter
1662  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
1663  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
1664  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
1665  global AWGABurstFlag, AWGACycles, AWGABurstDelay, AWGAwaveform, AWGAcsvFile, AWGBcsvFile
1666  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay, AWGBwaveform, AWGAwavFile, AWGBwavFile
1667  global SCLKPort, SDATAPort, SLATCHPort, EnableHSsampling, FminEntry, HtMulEntry
1668  global phawindow, PhAca, PhAScreenStatus, PhADisp
1669  global GRWPhA, X0LPhA, GRHPhA, Y0TPhA, EnableScopeOnly
1670  global VScale, IScale, RefphEntry, SMPfft, BoardStatus, boardwindow, BrdSel
1671  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn, iapbt_btn, RollBt, Roll_Mode
1672  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D, ScreenWidth, ScreenHeight
1673  global TRACEwidth, ColorMode, ca, COLORcanvas, COLORtrace4, COLORtraceR4, COLORtext
1674  global AWGANoiseEntry, AWGBNoiseEntry, AWGAsbnoise, AWGBsbnoise
1675  global AWGFiltA, AWGALenEntry, AWGFiltABoxCar, AWGFiltALength, digfltwindow
1676  global AWGFiltB, AWGBLenEntry, AWGFiltBBoxCar, AWGFiltBLength
1677  global COLORtext, COLORcanvas, COLORtrigger, COLORsignalband, COLORframes, COLORgrid, COLORzeroline
1678  global COLORtrace1, COLORtraceR1, COLORtrace2, COLORtraceR2, COLORtrace3, COLORtraceR3, COLORtrace4, COLORtraceR4
1679  global COLORtrace5, COLORtraceR5, COLORtrace6, COLORtraceR6, COLORtrace7, COLORtraceR7
1680  # Read configuration values from file
1681  try:
1682  ConfgFile = open(filename)
1683  for line in ConfgFile:
1684  try:
1685  exec( line.rstrip(), globals(), globals())
1686  #exec( line.rstrip() )
1687  except:
1688  print( "Skipping " + line.rstrip())
1689  ConfgFile.close()
1690  if ScreenWidth < root.winfo_x() or ScreenHeight < root.winfo_y(): # check if main window will be placed off screen?
1691  root.geometry('+0+0')
1692  try:
1693  if ScreenWidth < awgwindow.winfo_x() or ScreenHeight < awgwindow.winfo_y(): # check if AWG window will be placed off screen?
1694  awgwindow.geometry('+0+0')
1695  except:
1696  donothing()
1697  try:
1698  if ScreenWidth < xywindow.winfo_x() or ScreenHeight< xywindow.winfo_y(): # check if XY window will be placed off screen?
1699  xywindow.geometry('+0+0')
1700  except:
1701  donothing()
1702  try:
1703  if ScreenWidth < iawindow.winfo_x() or ScreenHeight < iawindow.winfo_y(): # check if IA window will be placed off screen?
1704  iawindow.geometry('+0+0')
1705  except:
1706  donothing()
1707  try:
1708  if ScreenWidth < freqwindow.winfo_x() or ScreenHeight < freqwindow.winfo_y(): # check if SA window will be placed off screen?
1709  freqwindow.geometry('+0+0')
1710  except:
1711  donothing()
1712  try:
1713  if ScreenWidth < win1.winfo_x() or ScreenHeight < win1.winfo_y(): # check if DAC1 window will be placed off screen?
1714  win1.geometry('+0+0')
1715  except:
1716  donothing()
1717  try:
1718  if ScreenWidth < win2.winfo_x() or ScreenHeight < win2.winfo_y(): # check if DAC2 window will be placed off screen?
1719  win2.geometry('+0+0')
1720  except:
1721  donothing()
1722  try:
1723  if ScreenWidth < minigenwindow.winfo_x() or ScreenHeight < minigenwindow.winfo_y(): # check if mini gen window will be placed off screen?
1724  minigenwindow.geometry('+0+0')
1725  except:
1726  donothing()
1727  try:
1728  if ScreenWidth < muxwindow.winfo_x() or ScreenHeight < muxwindow.winfo_y(): # check if mux window will be placed off screen?
1729  muxwindow.geometry('+0+0')
1730  except:
1731  donothing()
1732  try:
1733  if ScreenWidth < phawindow.winfo_x() or ScreenHeight < phawindow.winfo_y(): # check if PhA window will be placed off screen?
1734  phawindow.geometry('+0+0')
1735  except:
1736  donothing()
1737  try:
1738  if ScreenWidth < bodewindow.winfo_x() or ScreenHeight < bodewindow.winfo_y(): # check if Bode window will be placed off screen?
1739  bodewindow.geometry('+0+0')
1740  except:
1741  donothing()
1742  try:
1743  if ScreenWidth < measurewindow.winfo_x() or ScreenHeight < measurewindow.winfo_y(): # check if Measure window will be placed off screen?
1744  measurewindow.geometry('+0+0')
1745  except:
1746  donothing()
1747  try:
1748  if ScreenWidth < etswindow.winfo_x() or ScreenHeight < etswindow.winfo_y(): # check if ETS window will be placed off screen?
1749  etswindow.geometry('+0+0')
1750  except:
1751  donothing()
1752  if Roll_Mode.get() == 0:
1753  RollBt.config(style="RollOff.TButton",text="Roll-Off")
1754  else:
1755  RollBt.config(style="Roll.TButton",text="Roll-On")
1756  if DevID != "No Device":
1757  BAWGAModeLabel()
1758  BAWGBModeLabel()
1759  BAWGAPhaseDelay()
1760  BAWGBPhaseDelay()
1761 
1775  ca.config(background=COLORcanvas)
1776  # Needs to reload from waveform files
1777  if AWGAShape.get()==6:
1778  AWGALoadCSV()
1779  if AWGAShape.get()==13:
1780  AWGALoadWAV()
1781  if AWGBShape.get()==6:
1782  AWGBLoadCSV()
1783  if AWGBShape.get()==13:
1784  AWGBLoadWAV()
1785  # Regenerate waveform from formula
1786  if AWGAShape.get()==10:
1787  AWGAConfigMath()
1788  if AWGBShape.get()==10:
1789  AWGBConfigMath()
1790  if EnableScopeOnly == 0:
1791  UpdateAWGWin()
1792  TimeCheckBox()
1793  XYCheckBox()
1794  FreqCheckBox()
1795  BodeCheckBox()
1796  IACheckBox()
1797  OhmCheckBox()
1798  else:
1799  TimeCheckBox()
1800  XYCheckBox()
1801  UpdateAWGWin()
1802 #
1803  time.sleep(0.05)
1804  ReMakeAWGwaves()
1805  session.end() # Add this to turn off outputs after first time loading a config?
1806  BTime()
1807  except:
1808  print( "Config File Not Found.")
1809 
1810 
1811 def ReMakeAWGwaves(): # re make awg waveforms ib case something changed
1812  global AWGAShape, AWGBShape, BisCompA, AWGAShapeLabel, AWGBShapeLabel
1813  global AWGALength, AWGBLength, AWGAwaveform, AWGBwaveform, EnableScopeOnly
1814 
1815  if AWGAShape.get()==9:
1816  AWGAMakeImpulse()
1817  AWGAShapeLabel.config(text = "Impulse") # change displayed value
1818  elif AWGAShape.get()==11:
1820  AWGAShapeLabel.config(text = "Trapazoid") # change displayed value
1821  elif AWGAShape.get()==15:
1822  AWGAMakeSSQ()
1823  AWGAShapeLabel.config(text = "SSQ Pulse") # change displayed value
1824  elif AWGAShape.get()==16:
1825  AWGAMakeRamp()
1826  AWGAShapeLabel.config(text = "Ramp") # change displayed value
1827  elif AWGAShape.get()==17:
1828  AWGAMakePWMSine()
1829  AWGAShapeLabel.config(text = "PWN Sine") # change displayed value
1830  elif AWGAShape.get()==18:
1832  AWGAShapeLabel.config(text = "Hi Res Sine") # change displayed value
1833  elif AWGAShape.get()==12:
1835  AWGAShapeLabel.config(text = "Up Down Ramp") # change displayed value
1836  elif AWGAShape.get()==14:
1837  AWGAMakeFourier()
1838  AWGAShapeLabel.config(text = "Fourier Series") # change displayed value
1839  elif AWGAShape.get()==19:
1840  AWGAMakeSinc()
1841  AWGAShapeLabel.config(text = "Sinc Pulse") # change displayed value
1842  elif AWGAShape.get()==20:
1843  AWGAMakePulse()
1844  AWGAShapeLabel.config(text = "Pulse") # change displayed value
1845  elif AWGAShape.get()==21:
1846  AWGAMakeFMSine()
1847  AWGAShapeLabel.config(text = "FM Sine") # change displayed value
1848  elif AWGAShape.get()==22:
1849  AWGAMakeAMSine()
1850  AWGAShapeLabel.config(text = "AM Sine") # change displayed value
1851  elif AWGAShape.get()==23:
1853  AWGAShapeLabel.config(text = "Full Wave") # change displayed value
1854  elif AWGAShape.get()==24:
1856  AWGAShapeLabel.config(text = "Half Wave") # change displayed value
1857  elif AWGAShape.get()==7:
1858  AWGAMakeUUNoise()
1859  AWGAShapeLabel.config(text = "UU Noise") # change displayed value
1860  elif AWGAShape.get()==8:
1861  AWGAMakeUGNoise()
1862  AWGAShapeLabel.config(text = "UG Noise") # change displayed value
1863  elif AWGAShape.get()==0:
1864  AWGAShapeLabel.config(text = "DC") # change displayed value
1865  elif AWGAShape.get()==2:
1866  AWGAShapeLabel.config(text = "Triangle") # change displayed value
1867  elif AWGAShape.get()==4:
1868  AWGAShapeLabel.config(text = "Square") # change displayed value
1869  elif AWGAShape.get()==3:
1870  AWGAShapeLabel.config(text = "Saw Tooth") # change displayed value
1871  elif AWGAShape.get()==5:
1872  AWGAShapeLabel.config(text = "Starestep") # change displayed value
1873  elif AWGAShape.get()==6:
1874  AWGAShapeLabel.config(text = "CSV File") # change displayed value
1875  elif AWGAShape.get()==13:
1876  AWGAShapeLabel.config(text = "Wav File") # change displayed value
1877  elif AWGAShape.get()==10:
1878  AWGAShapeLabel.config(text = "Math") # change displayed value
1879  else:
1880  AWGAShapeLabel.config(text = "Other Shape") # change displayed value
1881 #
1882  if BisCompA.get() == 1:
1883  SetBCompA()
1884  if AWGBShape.get()==9:
1885  AWGBMakeImpulse()
1886  AWGBShapeLabel.config(text = "Impulse") # change displayed value
1887  elif AWGBShape.get()==11:
1889  AWGBShapeLabel.config(text = "Trapazoid") # change displayed value
1890  elif AWGBShape.get()==15:
1891  AWGBMakeSSQ()
1892  AWGBShapeLabel.config(text = "SSQ Pulse") # change displayed value
1893  elif AWGBShape.get()==16:
1894  AWGBMakeRamp()
1895  AWGBShapeLabel.config(text = "Ramp") # change displayed value
1896  elif AWGBShape.get()==17:
1897  AWGBMakePWMSine()
1898  AWGBShapeLabel.config(text = "PWN Sine") # change displayed value
1899  elif AWGBShape.get()==18:
1901  AWGBShapeLabel.config(text = "Hi Res Sine") # change displayed value
1902  elif AWGBShape.get()==12:
1904  AWGBShapeLabel.config(text = "Up Down Ramp") # change displayed value
1905  elif AWGBShape.get()==14:
1906  AWGBMakeFourier()
1907  AWGBShapeLabel.config(text = "Fourier Series") # change displayed value
1908  elif AWGBShape.get()==19:
1909  AWGBMakeSinc()
1910  AWGBShapeLabel.config(text = "Sinc Pulse") # change displayed value
1911  elif AWGBShape.get()==20:
1912  AWGBMakePulse()
1913  AWGBShapeLabel.config(text = "Pulse") # change displayed value
1914  elif AWGBShape.get()==23:
1916  AWGBShapeLabel.config(text = "Full Wave") # change displayed value
1917  elif AWGBShape.get()==24:
1919  AWGBShapeLabel.config(text = "Half Wave") # change displayed value
1920  elif AWGBShape.get()==7:
1921  AWGBMakeUUNoise()
1922  AWGBShapeLabel.config(text = "UU Noise") # change displayed value
1923  elif AWGBShape.get()==8:
1924  AWGBMakeUGNoise()
1925  AWGBShapeLabel.config(text = "UG Noise") # change displayed value
1926  elif AWGBShape.get()==0:
1927  AWGBShapeLabel.config(text = "DC") # change displayed value
1928  elif AWGBShape.get()==2:
1929  AWGBShapeLabel.config(text = "Triangle") # change displayed value
1930  elif AWGBShape.get()==4:
1931  AWGBShapeLabel.config(text = "Square") # change displayed value
1932  elif AWGBShape.get()==3:
1933  AWGBShapeLabel.config(text = "Saw Tooth") # change displayed value
1934  elif AWGBShape.get()==5:
1935  AWGBShapeLabel.config(text = "Starestep") # change displayed value
1936  elif AWGBShape.get()==6:
1937  AWGBShapeLabel.config(text = "CSV File") # change displayed value
1938  elif AWGBShape.get()==13:
1939  AWGBShapeLabel.config(text = "Wav File") # change displayed value
1940  elif AWGBShape.get()==10:
1941  AWGBShapeLabel.config(text = "Math") # change displayed value
1942  else:
1943  AWGBShapeLabel.config(text = "Other Shape") # change displayed value
1944  if EnableScopeOnly == 0:
1945  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
1946  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
1947  UpdateAwgCont()
1948  time.sleep(0.05)
1949 
1950 def BLoadConfigIA():
1951  global iawindow
1952 
1953  filename = askopenfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=iawindow)
1954  BLoadConfig(filename)
1955 
1956 def BLoadConfigSA():
1957  global freqwindow
1958 
1959  filename = askopenfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=freqwindow)
1960  BLoadConfig(filename)
1961 
1962 def BLoadConfigBP():
1963  global bodewindow
1964 
1965  filename = askopenfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=bodewindow)
1966  BLoadConfig(filename)
1967 
1968 def BLoadConfigTime():
1969  global root
1970 
1971  filename = askopenfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=root)
1972  BLoadConfig(filename)
1973  UpdateTimeTrace()
1974 
1975 def RunScript():
1976  global VBuffA, VBuffB, IBuffA, IBuffB, VFilterA, VFilterB
1977  global VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGAwaveform, AWGBwaveform
1978  global VUnAvgA, VUnAvgB, IUnAvgA, IUnAvgB, UnAvgSav
1979  global TgInput, TgEdge, SingleShot, AutoLevel, SingleShotSA, ManualTrigger
1980  global root, freqwindow, awgwindow, iawindow, xywindow, win1, win2
1981  global TRIGGERentry, TMsb, Xsignal, AutoCenterA, AutoCenterB
1982  global YsignalVA, YsignalIA, YsignalVB, YsignalIB, YsignalM, YsignalMX, YsignalMY
1983  global CHAsb, CHAIsb, CHBsb, CHBIsb, HScale, FreqTraceMode
1984  global CHAsbxy, CHAIsbxy, CHBsbxy, CHBIsbxy, HoldOffentry
1985  global CHAVPosEntryxy, CHBVPosEntryxy, CHAIPosEntryxy, CHBIPosEntryxy
1986  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, MathTrace, MathXUnits, MathYUnits
1987  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry, HozPossentry
1988  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGADutyCycleEntry
1989  global AWGAPhaseEntry, AWGAShape, AWGATerm, AWGAMode, AWGARepeatFlag, AWGBRepeatFlag
1990  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBDutyCycleEntry
1991  global AWGBPhaseEntry, AWGBShape, AWGBTerm, AWGBMode, AWGSync, AWGAIOMode, AWGBIOMode
1992  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
1993  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1, MeasDCI1, MeasMinI1
1994  global MeasMaxI1, MeasMidI1, MeasPPI1, MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2
1995  global MeasPPV2, MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2, MeasDiffAB, MeasDiffBA
1996  global MeasRMSV1, MeasRMSV2, MeasRMSI1, MeasRMSI2, MeasPhase, MeasDelay
1997  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ, IASource, DisplaySeries
1998  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
1999  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
2000  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, CutDC, AWG_Amp_Mode
2001  global FFTwindow, DBdivindex, DBlevel, TRACEmodeTime, TRACEaverage, Vdiv
2002  global SMPfftpwrTwo, SMPfft, StartFreqEntry, StopFreqEntry, ZEROstuffing
2003  global TimeDisp, XYDisp, FreqDisp, IADisp, AWGAPhaseDelay, AWGBPhaseDelay
2004  global RsystemEntry, ResScale, GainCorEntry, PhaseCorEntry
2005  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2
2006  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxScreenStatus, MuxEnb
2007  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry, muxwindow, ChopMuxMode, ChopTrig, DualMuxMode
2008  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
2009  global MathString, MathXString, MathYString, UserAString, UserALabel, UserBString, UserBLabel
2010  global MathAxis, MathXAxis, MathYAxis, Show_MathX, Show_MathY, MathScreenStatus, MathWindow
2011  global AWGAMathString, AWGBMathString, FFTUserWindowString, DigFilterAString, DigFilterBString
2012  global GRWF, GRHF, GRWBP, GRHBP, GRWXY, GRHXY, GRWIA, GRHIA, MeasureStatus
2013  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
2014  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
2015  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
2016  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
2017  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2, CHAI_RC_HP, CHBI_RC_HP
2018  global CHA_A1, CHA_A2, CHB_A1, CHB_A2, RelPhaseCenter, ImpedanceCenter
2019  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
2020  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
2021  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
2022  global AWGABurstFlag, AWGACycles, AWGABurstDelay, AWGAwaveform, AWGAcsvFile, AWGBcsvFile
2023  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay, AWGBwaveform, AWGAwavFile, AWGBwavFile
2024  global SCLKPort, SDATAPort, SLATCHPort, EnableHSsampling, FminEntry, HtMulEntry
2025  global phawindow, PhAca, PhAScreenStatus, PhADisp
2026  global GRWPhA, X0LPhA, GRHPhA, Y0TPhA, EnableScopeOnly
2027  global VScale, IScale, RefphEntry, SMPfft, BoardStatus, boardwindow, BrdSel
2028  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn, RollBt, Roll_Mode
2029  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D, ScreenWidth, ScreenHeight
2030  global TRACEwidth, ColorMode, ca, COLORcanvas, COLORtrace4, COLORtraceR4, COLORtext
2031  global AWGANoiseEntry, AWGBNoiseEntry, AWGAsbnoise, AWGBsbnoise
2032  global AWGFiltA, AWGALenEntry, AWGFiltABoxCar, AWGFiltALength, digfltwindow
2033  global AWGFiltB, AWGBLenEntry, AWGFiltBBoxCar, AWGFiltBLength
2034  global DFiltACoef, DFiltBCoef, AWGACoef, AWGBCoef
2035 
2036  filename = askopenfilename(defaultextension = ".txt", filetypes=[("Script files", "*.txt")], parent=root)
2037  # Read Script commands from file
2038  try:
2039  ConfgFile = open(filename)
2040  for line in ConfgFile:
2041  try:
2042  exec( line.rstrip(), globals(), globals())
2043  # exec( line.rstrip() )
2044  except:
2045  print( "Skipping " + line.rstrip())
2046  showwarning("Syntax Error!",("Syntax Error found in line:\n " + line.rstrip()))
2047  ConfgFile.close()
2048  except:
2049  print( "Config File Not Found.")
2050  showwarning("Warning!","Script File Not Found.")
2051 
2052 
2053 def BgColor():
2054  global COLORtext, COLORcanvas, ColorMode, Bodeca, BodeScreenStatus, PhAca, PhAScreenStatus
2055  global ca, Freqca, SpectrumScreenStatus, XYca, XYScreenStatus, IAca, IAScreenStatus
2056  global COLORtrace4, COLORtraceR4, TRACEwidth
2057 
2058  if ColorMode.get() > 0: # White background
2059  if TRACEwidth.get() < 2:
2060  TRACEwidth.set(2)
2061  COLORtext = "#000000" # 100% black
2062  COLORtrace4 = "#a0a000" # 50% yellow
2063  COLORtraceR4 = "#606000" # 25% yellow
2064  COLORcanvas = "#ffffff" # 100% white
2065  else:
2066  COLORcanvas = "#000000" # 100% black
2067  COLORtrace4 = "#ffff00" # 100% yellow
2068  COLORtraceR4 = "#808000" # 50% yellow
2069  COLORtext = "#ffffff" # 100% white
2070  ca.config(background=COLORcanvas)
2072  if SpectrumScreenStatus.get() > 0:
2073  Freqca.config(background=COLORcanvas)
2075  if XYScreenStatus.get() > 0:
2076  XYca.config(background=COLORcanvas)
2077  UpdateXYScreen()
2078  if PhAScreenStatus.get() > 0:
2079  PhAca.config(background=COLORcanvas)
2080  UpdatePhAScreen()
2081  if IAScreenStatus.get() > 0:
2082  IAca.config(background=COLORcanvas)
2083  UpdateIAScreen()
2084  if BodeScreenStatus.get() > 0:
2085  Bodeca.config(background=COLORcanvas)
2087 
2089  global ColorScreenStatus, FrameBG, SWRev, RevDate, ColorWindow
2090  global COLORtext, COLORcanvas, COLORtrigger, COLORsignalband, COLORframes, COLORgrid, COLORzeroline
2091  global COLORtrace1, COLORtraceR1, COLORtrace2, COLORtraceR2, COLORtrace3, COLORtraceR3, COLORtrace4, COLORtraceR4
2092  global COLORtrace5, COLORtraceR5, COLORtrace6, COLORtraceR6, COLORtrace7, COLORtraceR7
2093 
2094  if ColorScreenStatus.get() == 0:
2095  ColorScreenStatus.set(1)
2096  #
2097  ColorWindow = Toplevel()
2098  ColorWindow.title("Color Selector " + SWRev + RevDate)
2099  ColorWindow.resizable(FALSE,FALSE)
2100  ColorWindow.protocol("WM_DELETE_WINDOW", DestroyColorScreen)
2101  ColorWindow.configure(background=FrameBG)
2102 
2103  Colorframe1 = LabelFrame(ColorWindow, text="Trace Colors", style="A10R1.TLabelframe") #"A10T5.TLabelframe")
2104  Colorframe1.pack(side=TOP, expand=1, fill=Y)
2105  # Color value = "#rrggbb" rr=red gg=green bb=blue, Hexadecimal values 00 - ff
2106  trace1bt = Button(Colorframe1, text="COLORtrace1", style="T1W16.TButton", command=SetColorT1 ) #COLORtrace1 = "#00ff00" # 100% green
2107  trace1bt.grid(row=0, column=0, columnspan=1, sticky=W)
2108  #
2109  trace2bt = Button(Colorframe1, text="COLORtrace2", style="T2W16.TButton", command=SetColorT2 ) #COLORtrace2 = "#ff8000" # 100% orange
2110  trace2bt.grid(row=0, column=1, columnspan=1, sticky=W)
2111  #
2112  trace3bt = Button(Colorframe1, text="COLORtrace3", style="T3W16.TButton", command=SetColorT3 ) #COLORtrace3 = "#00ffff" # 100% cyan
2113  trace3bt.grid(row=0, column=2, columnspan=1, sticky=W)
2114  #
2115  trace4bt = Button(Colorframe1, text="COLORtrace4", style="T4W16.TButton", command=SetColorT4 ) #COLORtrace4 = "#ffff00" # 100% yellow
2116  trace4bt.grid(row=0, column=3, columnspan=1, sticky=W)
2117  #
2118  trace5bt = Button(Colorframe1, text="COLORtrace5", style="T5W16.TButton", command=SetColorT5 ) #COLORtrace5 = "#ff00ff" # 100% magenta
2119  trace5bt.grid(row=1, column=0, columnspan=1, sticky=W)
2120  #
2121  trace6bt = Button(Colorframe1, text="COLORtrace6", style="T6W16.TButton", command=SetColorT6 ) #COLORtrace6 = "#C80000" # 90% red
2122  trace6bt.grid(row=1, column=1, columnspan=1, sticky=W)
2123  #
2124  trace7bt = Button(Colorframe1, text="COLORtrace7", style="T7W16.TButton", command=SetColorT7 ) #COLORtrace7 = "#8080ff" # 100% purple
2125  trace7bt.grid(row=1, column=2, columnspan=1, sticky=W)
2126  #
2127  tracer1bt = Button(Colorframe1, text="COLORtraceR1", style="TR1W16.TButton", command=SetColorTR1 ) #COLORtraceR1 = "#008000" # 50% green
2128  tracer1bt.grid(row=2, column=0, columnspan=1, sticky=W)
2129  #
2130  tracer2rbt = Button(Colorframe1, text="COLORtraceR2", style="TR2W16.TButton", command=SetColorTR2 ) #COLORtraceR2 = "#905000" # 50% orange
2131  tracer2rbt.grid(row=2, column=1, columnspan=1, sticky=W)
2132  #
2133  tracer3bt = Button(Colorframe1, text="COLORtraceR3", style="TR3W16.TButton", command=SetColorTR3 ) #COLORtraceR3 = "#008080" # 50% cyan
2134  tracer3bt.grid(row=2, column=2, columnspan=1, sticky=W)
2135  #
2136  tracer4bt = Button(Colorframe1, text="COLORtraceR4", style="TR4W16.TButton", command=SetColorTR4 ) #COLORtraceR4 = "#808000" # 50% yellow
2137  tracer4bt.grid(row=2, column=3, columnspan=1, sticky=W)
2138  #
2139  tracer5bt = Button(Colorframe1, text="COLORtraceR5", style="TR5W16.TButton", command=SetColorTR5 ) #COLORtraceR5 = "#800080" # 50% magenta
2140  tracer5bt.grid(row=3, column=0, columnspan=1, sticky=W)
2141  #
2142  tracer6bt = Button(Colorframe1, text="COLORtraceR6", style="TR6W16.TButton", command=SetColorTR6 ) #COLORtraceR6 = "#800000" # 80% red
2143  tracer6bt.grid(row=3, column=1, columnspan=1, sticky=W)
2144  #
2145  tracer7bt = Button(Colorframe1, text="COLORtraceR7", style="TR7W16.TButton", command=SetColorTR7 ) #COLORtraceR7 = "#4040a0" # 80% purple
2146  tracer7bt.grid(row=3, column=2, columnspan=1, sticky=W)
2147  #
2148  gridbt = Button(Colorframe1, text="COLORgrid", style="W16.TButton", command=SetColorGrid ) #COLORgrid = "#808080" # 50% Gray
2149  gridbt.grid(row=4, column=0, columnspan=1, sticky=W)
2150  zerolinebt = Button(Colorframe1, text="COLORzeroline", style="ZLW16.TButton", command=SetColorZLine ) #COLORzeroline = "#0000ff" # 100% blue
2151  zerolinebt.grid(row=4, column=1, columnspan=1, sticky=W)
2152  ctriggerbt = Button(Colorframe1, text="COLORtrigger", style="TGW16.TButton", command=SetColorTrig ) #COLORtrigger = "#ff0000" # 100% red
2153  ctriggerbt.grid(row=4, column=2, columnspan=1, sticky=W)
2154  #
2155  ctextbt = Button(Colorframe1, text="COLORtext", style="W16.TButton", command=SetColorText ) #COLORtext = "#ffffff" # 100% white
2156  ctextbt.grid(row=4, column=3, columnspan=1, sticky=W)
2157  #
2158  cdismissbt = Button(Colorframe1, text="Dismiss", style="W16.TButton", command=DestroyColorScreen )
2159  cdismissbt.grid(row=5, column=0, columnspan=1, sticky=W)
2160  cresetbt = Button(Colorframe1, text="Reset Colors", style="W16.TButton", command=ResetAllColors )
2161  cresetbt.grid(row=5, column=1, columnspan=1, sticky=W)
2162 
2164  global ColorScreenStatus, ColorWindow
2165 
2166  if ColorScreenStatus.get() == 1:
2167  ColorScreenStatus.set(0)
2168  ColorWindow.destroy()
2169 
2171  global COLORtext, COLORcanvas, COLORtrigger, COLORsignalband, COLORframes, COLORgrid, COLORzeroline
2172  global COLORtrace1, COLORtraceR1, COLORtrace2, COLORtraceR2, COLORtrace3, COLORtraceR3, COLORtrace4, COLORtraceR4
2173  global COLORtrace5, COLORtraceR5, COLORtrace6, COLORtraceR6, COLORtrace7, COLORtraceR7
2174 
2175  ResetColors()
2176  root.style.configure("T1W16.TButton", background=COLORtrace1)
2177  root.style.configure("Rtrace1.TButton", background=COLORtrace1)
2178  root.style.configure("Strace1.TButton", background=COLORtrace1)
2179  root.style.configure("Ctrace1.TButton", background=COLORtrace1)
2180  root.style.configure("Strace1.TCheckbutton", background=COLORtrace1)
2181  root.style.configure("T2W16.TButton", background=COLORtrace2)
2182  root.style.configure("Rtrace2.TButton", background=COLORtrace2)
2183  root.style.configure("Strace2.TButton", background=COLORtrace2)
2184  root.style.configure("Ctrace2.TButton", background=COLORtrace2)
2185  root.style.configure("Strace2.TCheckbutton", background=COLORtrace2)
2186  root.style.configure("T3W16.TButton", background=COLORtrace3)
2187  root.style.configure("Rtrace3.TButton", background=COLORtrace3)
2188  root.style.configure("Strace3.TButton", background=COLORtrace3)
2189  root.style.configure("Ctrace3.TButton", background=COLORtrace3)
2190  root.style.configure("Strace3.TCheckbutton", background=COLORtrace3)
2191  root.style.configure("T4W16.TButton", background=COLORtrace4)
2192  root.style.configure("Rtrace4.TButton", background=COLORtrace4)
2193  root.style.configure("Strace4.TButton", background=COLORtrace4)
2194  root.style.configure("Ctrace4.TButton", background=COLORtrace4)
2195  root.style.configure("Strace4.TCheckbutton", background=COLORtrace4)
2196  root.style.configure("T5W16.TButton", background=COLORtrace5)
2197  root.style.configure("T6W16.TButton", background=COLORtrace6)
2198  root.style.configure("Rtrace6.TButton", background=COLORtrace6)
2199  root.style.configure("Strace6.TButton", background=COLORtrace6)
2200  root.style.configure("Strace6.TCheckbutton", background=COLORtrace6)
2201  root.style.configure("T7W16.TButton", background=COLORtrace7)
2202  root.style.configure("Rtrace7.TButton", background=COLORtrace7)
2203  root.style.configure("Strace7.TButton", background=COLORtrace7)
2204  root.style.configure("Strace7.TCheckbutton", background=COLORtrace7)
2205  root.style.configure("TR1W16.TButton", background=COLORtraceR1)
2206  root.style.configure("TR2W16.TButton", background=COLORtraceR2)
2207  root.style.configure("TR3W16.TButton", background=COLORtraceR3)
2208  root.style.configure("TR4W16.TButton", background=COLORtraceR4)
2209  root.style.configure("TR5W16.TButton", background=COLORtraceR6)
2210  root.style.configure("TR6W16.TButton", background=COLORtraceR5)
2211  root.style.configure("TR5W16.TButton", background=COLORtraceR7)
2212  root.style.configure("TGW16.TButton", background=COLORtrigger)
2213 
2215  global COLORtrace1
2216 
2217  tempwindow = Tk()
2218  tempwindow.state("withdrawn")
2219  rgb,hexcolor = askcolor(parent=tempwindow, title="Choose color for COLORtrace1", initialcolor=(COLORtrace1))
2220  tempwindow.destroy()
2221  if hexcolor != None:
2222  COLORtrace1 = str(hexcolor) # hexcolor
2223  root.style.configure("T1W16.TButton", background=COLORtrace1)
2224  root.style.configure("Rtrace1.TButton", background=COLORtrace1)
2225  root.style.configure("Strace1.TButton", background=COLORtrace1)
2226  root.style.configure("Ctrace1.TButton", background=COLORtrace1)
2227  root.style.configure("Strace1.TCheckbutton", background=COLORtrace1)
2228 
2230  global COLORtrace2
2231 
2232  tempwindow = Tk()
2233  tempwindow.state("withdrawn")
2234  rgb,hexcolor = askcolor(parent=tempwindow, title="Choose color for COLORtrace2", initialcolor=(COLORtrace2))
2235  tempwindow.destroy()
2236  if hexcolor != None:
2237  COLORtrace2 = str(hexcolor) # hexcolor
2238  root.style.configure("T2W16.TButton", background=COLORtrace2)
2239  root.style.configure("Rtrace2.TButton", background=COLORtrace2)
2240  root.style.configure("Strace2.TButton", background=COLORtrace2)
2241  root.style.configure("Ctrace2.TButton", background=COLORtrace2)
2242  root.style.configure("Strace2.TCheckbutton", background=COLORtrace2)
2243 
2245  global COLORtrace3
2246 
2247  tempwindow = Tk()
2248  tempwindow.state("withdrawn")
2249  rgb,hexcolor = askcolor(parent=tempwindow, title="Choose color for COLORtrace3", initialcolor=(COLORtrace3))
2250  tempwindow.destroy()
2251  if hexcolor != None:
2252  COLORtrace3 = str(hexcolor) # hexcolor
2253  root.style.configure("T3W16.TButton", background=COLORtrace3)
2254  root.style.configure("Rtrace3.TButton", background=COLORtrace3)
2255  root.style.configure("Strace3.TButton", background=COLORtrace3)
2256  root.style.configure("Ctrace3.TButton", background=COLORtrace3)
2257  root.style.configure("Strace3.TCheckbutton", background=COLORtrace3)
2258 
2260  global COLORtrace4
2261 
2262  tempwindow = Tk()
2263  tempwindow.state("withdrawn")
2264  rgb,hexcolor = askcolor(parent=tempwindow, title="Choose color for COLORtrace4", initialcolor=(COLORtrace4))
2265  tempwindow.destroy()
2266  if hexcolor != None:
2267  COLORtrace4 = str(hexcolor) # hexcolor
2268  root.style.configure("T4W16.TButton", background=COLORtrace4)
2269  root.style.configure("Rtrace4.TButton", background=COLORtrace4)
2270  root.style.configure("Strace4.TButton", background=COLORtrace4)
2271  root.style.configure("Ctrace4.TButton", background=COLORtrace4)
2272  root.style.configure("Strace4.TCheckbutton", background=COLORtrace4)
2273 
2275  global COLORtrace5
2276 
2277  tempwindow = Tk()
2278  tempwindow.state("withdrawn")
2279  rgb,hexcolor = askcolor(parent=tempwindow, title="Choose color for COLORtrace5", initialcolor=(COLORtrace5))
2280  tempwindow.destroy()
2281  if hexcolor != None:
2282  COLORtrace5 = str(hexcolor) # hexcolor
2283  root.style.configure("T5W16.TButton", background=COLORtrace5)
2284 
2286  global COLORtrace6
2287 
2288  tempwindow = Tk()
2289  tempwindow.state("withdrawn")
2290  rgb,hexcolor = askcolor(parent=tempwindow, title="Choose color for COLORtrace6", initialcolor=(COLORtrace6))
2291  tempwindow.destroy()
2292  if hexcolor != None:
2293  COLORtrace6 = str(hexcolor) # hexcolor
2294  root.style.configure("T6W16.TButton", background=COLORtrace6)
2295  root.style.configure("Rtrace6.TButton", background=COLORtrace6)
2296  root.style.configure("Strace6.TButton", background=COLORtrace6)
2297  root.style.configure("Strace6.TCheckbutton", background=COLORtrace6)
2298 
2300  global COLORtrace7
2301 
2302  tempwindow = Tk()
2303  tempwindow.state("withdrawn")
2304  rgb,hexcolor = askcolor(parent=tempwindow, title="Choose color for COLORtrace7", initialcolor=(COLORtrace7))
2305  tempwindow.destroy()
2306  if hexcolor != None:
2307  COLORtrace7 = str(hexcolor) # hexcolor
2308  root.style.configure("T7W16.TButton", background=COLORtrace7)
2309  root.style.configure("Rtrace7.TButton", background=COLORtrace7)
2310  root.style.configure("Strace7.TButton", background=COLORtrace7)
2311  root.style.configure("Strace7.TCheckbutton", background=COLORtrace7)
2312 
2314  global COLORtraceR1
2315 
2316  tempwindow = Tk()
2317  tempwindow.state("withdrawn")
2318  rgb,hexcolor = askcolor(parent=tempwindow, title="Choose color for COLORtraceR1", initialcolor=(COLORtraceR1))
2319  tempwindow.destroy()
2320  if hexcolor != None:
2321  COLORtraceR1 = str(hexcolor) # hexcolor
2322  root.style.configure("TR1W16.TButton", background=COLORtraceR1)
2323 
2325  global COLORtraceR2
2326 
2327  tempwindow = Tk()
2328  tempwindow.state("withdrawn")
2329  rgb,hexcolor = askcolor(parent=tempwindow, title="Choose color for COLORtraceR2", initialcolor=(COLORtraceR2))
2330  tempwindow.destroy()
2331  if hexcolor != None:
2332  COLORtraceR2 = str(hexcolor) # hexcolor
2333  root.style.configure("TR2W16.TButton", background=COLORtraceR2)
2334 
2336  global COLORtraceR3
2337 
2338  tempwindow = Tk()
2339  tempwindow.state("withdrawn")
2340  rgb,hexcolor = askcolor(parent=tempwindow, title="Choose color for COLORtraceR3", initialcolor=(COLORtraceR3))
2341  tempwindow.destroy()
2342  if hexcolor != None:
2343  COLORtraceR3 = str(hexcolor) # hexcolor
2344  root.style.configure("TR3W16.TButton", background=COLORtraceR3)
2345 
2347  global COLORtraceR4
2348 
2349  tempwindow = Tk()
2350  tempwindow.state("withdrawn")
2351  rgb,hexcolor = askcolor(parent=tempwindow, title="Choose color for COLORtraceR4", initialcolor=(COLORtraceR4))
2352  tempwindow.destroy()
2353  if hexcolor != None:
2354  COLORtraceR4 = str(hexcolor) # hexcolor
2355  root.style.configure("TR4W16.TButton", background=COLORtraceR4)
2356 
2358  global COLORtraceR5
2359 
2360  tempwindow = Tk()
2361  tempwindow.state("withdrawn")
2362  rgb,hexcolor = askcolor(parent=tempwindow, title="Choose color for COLORtraceR5", initialcolor=(COLORtraceR5))
2363  tempwindow.destroy()
2364  if hexcolor != None:
2365  COLORtraceR5 = str(hexcolor) # hexcolor
2366  root.style.configure("TR5W16.TButton", background=COLORtraceR5)
2367 
2369  global COLORtraceR6
2370 
2371  tempwindow = Tk()
2372  tempwindow.state("withdrawn")
2373  rgb,hexcolor = askcolor(parent=tempwindow, title="Choose color for COLORtraceR6", initialcolor=(COLORtraceR6))
2374  tempwindow.destroy()
2375  if hexcolor != None:
2376  COLORtraceR6 = str(hexcolor) # hexcolor
2377  root.style.configure("TR6W16.TButton", background=COLORtraceR6)
2378 
2380  global COLORtraceR7
2381 
2382  tempwindow = Tk()
2383  tempwindow.state("withdrawn")
2384  rgb,hexcolor = askcolor(parent=tempwindow, title="Choose color for COLORtraceR7", initialcolor=(COLORtraceR7))
2385  tempwindow.destroy()
2386  if hexcolor != None:
2387  COLORtraceR7 = str(hexcolor) # hexcolor
2388  root.style.configure("TR7W16.TButton", background=COLORtraceR7)
2389 
2391  global COLORgrid
2392 
2393  tempwindow = Tk()
2394  tempwindow.state("withdrawn")
2395  rgb,hexcolor = askcolor(parent=tempwindow, title="Choose color for COLORgrid", initialcolor=(COLORgrid))
2396  tempwindow.destroy()
2397  if hexcolor != None:
2398  COLORgrid = str(hexcolor) # hexcolor
2399 
2401  global COLORtext
2402 
2403  tempwindow = Tk()
2404  tempwindow.state("withdrawn")
2405  rgb,hexcolor = askcolor(parent=tempwindow, title="Choose color for COLORtext", initialcolor=(COLORtext))
2406  tempwindow.destroy()
2407  if hexcolor != None:
2408  COLORtext = str(hexcolor) # hexcolor
2409 
2411  global COLORtrigger
2412 
2413  tempwindow = Tk()
2414  tempwindow.state("withdrawn")
2415  rgb,hexcolor = askcolor(parent=tempwindow, title="Choose color for COLORtrigger", initialcolor=(COLORtrigger))
2416  tempwindow.destroy()
2417  if hexcolor != None:
2418  COLORtrigger = str(hexcolor) # hexcolor
2419  root.style.configure("TGW16.TButton", background=COLORtrigger)
2420 
2422  global COLORzeroline
2423 
2424  tempwindow = Tk()
2425  tempwindow.state("withdrawn")
2426  rgb,hexcolor = askcolor(parent=tempwindow, title="Choose color for COLORzeroline", initialcolor=(COLORzeroline))
2427  tempwindow.destroy()
2428  if hexcolor != None:
2429  COLORzeroline = str(hexcolor) # hexcolor
2430  root.style.configure("ZLW16.TButton", background=COLORzeroline)
2431 #
2432 
2433 def BSaveScreen():
2434  global CANVASwidth, CANVASheight
2435  global COLORtext, MarkerNum, ColorMode
2436  # ask for file name
2437  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")])
2438  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n")
2439  if MarkerNum > 0 or ColorMode.get() > 0:
2440  ca.postscript(file=filename, height=CANVASheight, width=CANVASwidth, colormode='color', rotate=Orient)
2441  else: # temp chnage text corlor to black
2442  COLORtext = "#000000"
2444  # first save postscript file
2445  ca.postscript(file=filename, height=CANVASheight, width=CANVASwidth, colormode='color', rotate=Orient)
2446  # now convert to bit map
2447  # img = Image.open("screen_shot.eps")
2448  # img.save("screen_shot.gif", "gif")
2449  COLORtext = "#ffffff"
2451 
2452 def BSaveScreenXY():
2453  global CANVASwidthXY, CANVASheightXY, xywindow
2454  global COLORtext, MarkerNum, ColorMode, XYca
2455  # ask for file name
2456  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")], parent=xywindow)
2457  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n", parent=xywindow)
2458  if MarkerNum > 0 or ColorMode.get() > 0:
2459  XYca.postscript(file=filename, height=CANVASheightXY, width=CANVASwidthXY, colormode='color', rotate=Orient)
2460  else: # temp chnage text corlor to black
2461  COLORtext = "#000000"
2462  UpdateXYScreen()
2463  # first save postscript file
2464  XYca.postscript(file=filename, height=CANVASheightXY, width=CANVASwidthXY, colormode='color', rotate=Orient)
2465  # now convert to bit map
2466  # img = Image.open("screen_shot.eps")
2467  # img.save("screen_shot.gif", "gif")
2468  COLORtext = "#ffffff"
2469  UpdateXYScreen()
2470 
2471 def BSaveScreenIA():
2472  global CANVASwidthIA, CANVASheightIA
2473  global COLORtext, IAca, ColorMode, iawindow
2474  # ask for file name
2475  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")], parent=iawindow)
2476  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n", parent=iawindow)
2477  if ColorMode.get() > 0:
2478  IAca.postscript(file=filename, height=CANVASheightIA, width=CANVASwidthIA, colormode='color', rotate=Orient)
2479  else: # temp change text color to black for Black BG
2480  COLORtext = "#000000"
2481  UpdateIAScreen()
2482  # save postscript file
2483  IAca.postscript(file=filename, height=CANVASheightIA, width=CANVASwidthIA, colormode='color', rotate=Orient)
2484  #
2485  COLORtext = "#ffffff"
2486  UpdateIAScreen()
2487 
2488 def BSaveScreenBP():
2489  global CANVASwidthBP, CANVASheightBP
2490  global COLORtext, Bodeca, bodewindow
2491  # ask for file name
2492  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")], parent = bodewindow)
2493  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n", parent=bodewindow)
2494  if MarkerNum > 0 or ColorMode.get() > 0:
2495  Bodeca.postscript(file=filename, height=CANVASheightBP, width=CANVASwidthBP, colormode='color', rotate=Orient)
2496  else: # temp change text color to black
2497  COLORtext = "#000000"
2499  # save postscript file
2500  Bodeca.postscript(file=filename, height=CANVASheightBP, width=CANVASwidthBP, colormode='color', rotate=Orient)
2501  #
2502  COLORtext = "#ffffff"
2504 
2505 def BSaveData():
2506  global VBuffA, VBuffB, IBuffA, IBuffB, SAMPLErate
2507 
2508  # open file to save data
2509  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("Comma Separated Values", "*.csv")])
2510  DataFile = open(filename, 'w')
2511  DataFile.write( 'Sample-#, CA-V, CA-I, CB-V, CB-I \n' )
2512  for index in range(len(VBuffA)):
2513  if Roll_Mode.get() > 0:
2514  TimePnt = float(index+0.0)
2515  else:
2516  TimePnt = float((index+0.0)/SAMPLErate)
2517  DataFile.write( str(TimePnt) + ', ' + str(VBuffA[index]) + ', ' + str(IBuffA[index]) + ', '
2518  + str(VBuffB[index]) + ', ' + str(IBuffB[index]) + '\n')
2519  DataFile.close()
2520 
2521 def BSaveMuxData():
2522  global SAMPLErate, VBuffMA, VBuffMB, VBuffMC, VBuffMD
2523  # open file to save data
2524  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("Comma Separated Values", "*.csv")])
2525  DataFile = open(filename, 'w')
2526  DataFile.write( 'Sample-#, MuxA, MuxB, MuxC, MuxD \n' )
2527 
2528  for index in range(len(VBuffMA)):
2529  TimePnt = float((index+0.0)/SAMPLErate)
2530  DataFile.write( str(TimePnt) + ', ' + str(VBuffMA[index]) + ', ' + str(VBuffMB[index]) + ', '
2531  + str(VBuffMC[index]) + ', ' + str(VBuffMD[index]) + '\n')
2532  DataFile.close()
2533 
2534 
2535 def BSaveChannelData():
2536  global SAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB, VBuffMA, VBuffMB, VBuffMC, VBuffMD
2537 
2538  # ask user for channel to save
2539  Channel = askstring("Choose Channel", "CA-V, CB-V, CA-I, CB-I\n MuxA, MuxB, MuxC, MuxD \n Channel:\n", initialvalue="CA-V")
2540  if (Channel == None): # If Cancel pressed, then None
2541  return
2542  # open file to save data
2543  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("Comma Separated Values", "*.csv")])
2544  DataFile = open(filename, 'w')
2545  if Channel == "CA-V":
2546  DataFile.write( 'Sample-#, CA-V\n' )
2547  for index in range(len(VBuffA)):
2548  TimePnt = float((index+0.0)/SAMPLErate)
2549  DataFile.write( str(TimePnt) + ', ' + str(VBuffA[index]) + '\n')
2550  elif Channel == "CA-I":
2551  DataFile.write( 'Sample-#, CA-I,\n' )
2552  for index in range(len(IBuffA)):
2553  TimePnt = float((index+0.0)/SAMPLErate)
2554  DataFile.write( str(TimePnt) + ', ' + str(IBuffA[index]) + '\n')
2555  elif Channel == "CB-V":
2556  DataFile.write( 'Sample-#, CB-V\n' )
2557  for index in range(len(VBuffB)):
2558  TimePnt = float((index+0.0)/SAMPLErate)
2559  DataFile.write( str(TimePnt) + ', ' + str(VBuffB[index]) + '\n')
2560  elif Channel == "CB-I":
2561  DataFile.write( 'Sample-#, CB-I,\n' )
2562  for index in range(len(IBuffB)):
2563  TimePnt = float((index+0.0)/SAMPLErate)
2564  DataFile.write( str(TimePnt) + ', ' + str(IBuffB[index]) + '\n')
2565  elif Channel == "MuxA":
2566  DataFile.write( 'Sample-#, MuxA\n' )
2567  for index in range(len(VBuffMA)):
2568  TimePnt = float((index+0.0)/SAMPLErate)
2569  DataFile.write( str(TimePnt) + ', ' + str(VBuffMA[index]) + '\n')
2570  elif Channel == "MuxB":
2571  DataFile.write( 'Sample-#, MuxB\n' )
2572  for index in range(len(VBuffMB)):
2573  TimePnt = float((index+0.0)/SAMPLErate)
2574  DataFile.write( str(TimePnt) + ', ' + str(VBuffMB[index]) + '\n')
2575  elif Channel == "MuxC":
2576  DataFile.write( 'Sample-#, MuxC\n' )
2577  for index in range(len(VBuffMC)):
2578  TimePnt = float((index+0.0)/SAMPLErate)
2579  DataFile.write( str(TimePnt) + ', ' + str(VBuffMC[index]) + '\n')
2580  elif Channel == "MuxD":
2581  DataFile.write( 'Sample-#, MuxD\n' )
2582  for index in range(len(VBuffMD)):
2583  TimePnt = float((index+0.0)/SAMPLErate)
2584  DataFile.write( str(TimePnt) + ', ' + str(VBuffMD[index]) + '\n')
2585  DataFile.close()
2586 # place text string on clipboard
2587 def BSaveToClipBoard(TempBuffer):
2588  global VBuffA, VBuffB, IBuffA, IBuffB, VBuffMA, VBuffMB, VBuffMC, VBuffMD, SAMPLErate
2589 
2590  root.clipboard_clear()
2591  for index in range(len(TempBuffer)):
2592  root.clipboard_append(str(TempBuffer[index])+ '\n')
2593  root.update()
2594 
2595 # Get text string from clipboard
2596 def BReadFromClipboard():
2597 
2598  TempBuffer = []
2599  try:
2600  clip_text = root.clipboard_get()
2601  TempBuffer = numpy.fromstring( clip_text, dtype=float, sep='\n' )
2602  return(TempBuffer)
2603  except:
2604  return(TempBuffer)
2605 
2606 def BLoadDFiltAClip():
2607  global DFiltACoef
2608 
2609  DFiltACoef = BReadFromClipboard()
2610  DifFiltALength.config(text = "Length = " + str(int(len(DFiltACoef)))) # change displayed length value
2611 
2612 def BLoadDFiltBClip():
2613  global DFiltBCoef
2614 
2615  DFiltBCoef = BReadFromClipboard()
2616  DifFiltBLength.config(text = "Length = " + str(int(len(DFiltBCoef)))) # change displayed length value
2617 
2618 def BLoadAWGAFiltClip():
2619  global AWGFiltACoef
2620 
2621  AWGFiltACoef = BReadFromClipboard()
2622  AWGFiltALength.config(text = "Length = " + str(int(len(AWGFiltACoef)))) # change displayed length value
2623 
2624 def BLoadAWGBFiltClip():
2625  global AWGFiltBCoef
2626 
2627  AWGFiltBCoef = BReadFromClipboard()
2628  AWGFiltBLength.config(text = "Length = " + str(int(len(AWGFiltBCoef)))) # change displayed length value
2629 
2630 
2631 def BReadData():
2632  global VBuffA, VBuffB, IBuffA, IBuffB, SHOWsamples
2633 
2634  # Read values from CVS file
2635  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")])
2636  try:
2637  CSVFile = open(filename)
2638  dialect = csv.Sniffer().sniff(CSVFile.read(2048))
2639  CSVFile.seek(0)
2640  csv_f = csv.reader(CSVFile, dialect)
2641  VBuffA = []
2642  VBuffB = []
2643  IBuffA = []
2644  IBuffB = []
2645  SHOWsamples = 0
2646  for row in csv_f:
2647  try:
2648  VBuffA.append(float(row[1]))
2649  IBuffA.append(float(row[2]))
2650  VBuffB.append(float(row[3]))
2651  IBuffB.append(float(row[4]))
2652  SHOWsamples = SHOWsamples + 1
2653  except:
2654  print( 'skipping non-numeric row')
2655  VBuffA = numpy.array(VBuffA)
2656  IBuffA = numpy.array(IBuffA)
2657  VBuffB = numpy.array(VBuffB)
2658  IBuffB = numpy.array(IBuffB)
2659  CSVFile.close()
2660  UpdateTimeTrace()
2661  except:
2662  showwarning("WARNING","No such file found or wrong format!")
2663 
2665 def BHelp():
2666 
2667  url = "https://wiki.analog.com/university/tools/m1k/alice/desk-top-users-guide"
2668  webbrowser.open(url,new=2)
2669 
2670 def BAbout():
2671  global RevDate, SWRev, FWRevOne, HWRevOne, DevID, Version_url
2672 #Version_url = 'https://github.com/analogdevicesinc/alice/releases/download/1.3.8/alice-desktop-1.3-setup.exe'
2673  try:
2674  if sys.version_info[0] == 2:
2675  u = urllib2.urlopen(Version_url)
2676  if sys.version_info[0] == 3:
2677  u = urllib.request.urlopen(Version_url)
2678  meta = u.info()
2679  time_string = str(meta.getheaders("Last-Modified"))
2680  except:
2681  time_string = "Unavailable"
2682  showinfo("About ALICE", "ALICE DeskTop" + SWRev + RevDate + "\n" +
2683  "Last Released Version: " + time_string[7:18] + "\n" +
2684  "ADALM1000 Hardware Rev " + str(HWRevOne) + "\n" +
2685  "Firmware Rev " + str(FWRevOne) + "\n" +
2686  "Board Serial Number " + DevID + "\n" +
2687  "Software is provided as is without any Warranty")
2688 #
2689 
2690 def BSnapShot():
2691  global T1Vline, T2Vline, T1Iline, T2Iline
2692  global Tmathline, TMRline, TXYRline
2693  global T1VRline, T2VRline, T1IRline, T2IRline, TMCVline, TMDVline
2694  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, ShowMath, MathTrace
2695  global MuxScreenStatus, TMARline, TMBRline, TMCRline, TMDRline
2696  global TMAVline, TMBVline, TMCVline, TMDVline
2697  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxEnb
2698  global ShowRMA, ShowRMB, ShowRMC, ShowRMD
2699 
2700  if ShowC1_V.get() == 1:
2701  T1VRline = T1Vline # V reference Trace line channel A
2702  if ShowC2_V.get() == 1:
2703  T2VRline = T2Vline # V reference Trace line channel B
2704  if ShowC1_I.get() == 1:
2705  T1IRline = T1Iline # I reference Trace line channel A
2706  if ShowC2_I.get() == 1:
2707  T2IRline = T2Iline # I reference Trace line channel B
2708  if MathTrace.get() > 0:
2709  TMRline = Tmathline # Math reference Trace line
2710  if MuxScreenStatus.get() > 0:
2711  if Show_CBA.get() > 0:
2712  TMARline = TMAVline # V reference Trace line Mux channel A
2713  if Show_CBB.get() > 0:
2714  TMBRline = TMBVline # V reference Trace line Mux channel B
2715  if Show_CBC.get() > 0:
2716  TMCRline = TMCVline # V reference Trace line Mux channel C
2717  if Show_CBD.get() > 0:
2718  TMDRline = TMDVline # V reference Trace line Mux channel D
2719 #
2720 
2721 def BSnapShotXY():
2722  global XYlineVA, XYlineIA, XYlineVB, XYlineIB, XYlineM, XYlineMX, XYlineMY
2723  global XYRlineVA, XYRlineIA, XYRlineVB, XYRlineIB, XYRlineM, XYRlineMX, XYRlineMY
2724 
2725  if len(XYlineVA) > 4:
2726  XYRlineVA = XYlineVA
2727  if len(XYlineVB) > 4:
2728  XYRlineVB = XYlineVB
2729  if len(XYlineIA) > 4:
2730  XYRlineIA = XYlineIA
2731  if len(XYlineIB) > 4:
2732  XYRlineIB = XYlineIB
2733  if len(XYlineM) > 4:
2734  XYRlineM = XYlineM
2735  if len(XYlineMX) > 4:
2736  XYRlineMX = XYlineMX
2737  if len(XYlineMY) > 4:
2738  XYRlineMY = XYlineMY
2739 #
2740 
2741 def BSaveCal():
2742  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
2743  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
2744  global DevID
2745  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
2746  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
2747  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
2748  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
2749 
2750  devidstr = DevID[17:31]
2751  filename = devidstr + "_O.cal"
2752  CalFile = open(filename, "w")
2753  #
2754  CalFile.write('CHAVGainEntry.delete(0,END)\n')
2755  CalFile.write('CHAVGainEntry.insert(4, ' + CHAVGainEntry.get() + ')\n')
2756  CalFile.write('CHBVGainEntry.delete(0,END)\n')
2757  CalFile.write('CHBVGainEntry.insert(4, ' + CHBVGainEntry.get() + ')\n')
2758  CalFile.write('CHAVOffsetEntry.delete(0,END)\n')
2759  CalFile.write('CHAVOffsetEntry.insert(4, ' + CHAVOffsetEntry.get() + ')\n')
2760  CalFile.write('CHBVOffsetEntry.delete(0,END)\n')
2761  CalFile.write('CHBVOffsetEntry.insert(4, ' + CHBVOffsetEntry.get() + ')\n')
2762  #
2763  CalFile.write('CHAIGainEntry.delete(0,END)\n')
2764  CalFile.write('CHAIGainEntry.insert(4, ' + CHAIGainEntry.get() + ')\n')
2765  CalFile.write('CHBIGainEntry.delete(0,END)\n')
2766  CalFile.write('CHBIGainEntry.insert(4, ' + CHBIGainEntry.get() + ')\n')
2767  CalFile.write('CHAIOffsetEntry.delete(0,END)\n')
2768  CalFile.write('CHAIOffsetEntry.insert(4, ' + CHAIOffsetEntry.get() + ')\n')
2769  CalFile.write('CHBIOffsetEntry.delete(0,END)\n')
2770  CalFile.write('CHBIOffsetEntry.insert(4, ' + CHBIOffsetEntry.get() + ')\n')
2771  #
2772  # save channel AC frequency compensation settings
2773  try:
2774  CHA_TC1.set(float(cha_TC1Entry.get()))
2775  CHA_TC2.set(float(cha_TC2Entry.get()))
2776  CHB_TC1.set(float(chb_TC1Entry.get()))
2777  CHB_TC2.set(float(chb_TC2Entry.get()))
2778  CHA_A1.set(float(cha_A1Entry.get()))
2779  CHA_A2.set(float(cha_A2Entry.get()))
2780  CHB_A1.set(float(chb_A1Entry.get()))
2781  CHB_A2.set(float(chb_A2Entry.get()))
2782  except:
2783  donothing()
2784  CalFile.write('CHA_RC_HP.set(' + str(CHA_RC_HP.get()) + ')\n')
2785  CalFile.write('CHB_RC_HP.set(' + str(CHB_RC_HP.get()) + ')\n')
2786  CalFile.write('CHA_TC1.set(' + str(CHA_TC1.get()) + ')\n')
2787  CalFile.write('CHA_TC2.set(' + str(CHA_TC2.get()) + ')\n')
2788  CalFile.write('CHB_TC1.set(' + str(CHB_TC1.get()) + ')\n')
2789  CalFile.write('CHB_TC2.set(' + str(CHB_TC2.get()) + ')\n')
2790  CalFile.write('CHA_A1.set(' + str(CHA_A1.get()) + ')\n')
2791  CalFile.write('CHA_A2.set(' + str(CHA_A2.get()) + ')\n')
2792  CalFile.write('CHB_A1.set(' + str(CHB_A1.get()) + ')\n')
2793  CalFile.write('CHB_A2.set(' + str(CHB_A2.get()) + ')\n')
2794  CalFile.write('cha_TC1Entry.delete(0,END)\n')
2795  CalFile.write('cha_TC1Entry.insert(4, ' + str(CHA_TC1.get()) + ')\n')
2796  CalFile.write('cha_TC2Entry.delete(0,END)\n')
2797  CalFile.write('cha_TC2Entry.insert(4, ' + str(CHA_TC2.get()) + ')\n')
2798  CalFile.write('chb_TC1Entry.delete(0,END)\n')
2799  CalFile.write('chb_TC1Entry.insert(4, ' + str(CHB_TC1.get()) + ')\n')
2800  CalFile.write('chb_TC2Entry.delete(0,END)\n')
2801  CalFile.write('chb_TC2Entry.insert(4, ' + str(CHB_TC2.get()) + ')\n')
2802  CalFile.write('cha_A1Entry.delete(0,END)\n')
2803  CalFile.write('cha_A1Entry.insert(4, ' + str(CHA_A1.get()) + ')\n')
2804  CalFile.write('cha_A2Entry.delete(0,END)\n')
2805  CalFile.write('cha_A2Entry.insert(4, ' + str(CHA_A2.get()) + ')\n')
2806  CalFile.write('chb_A1Entry.delete(0,END)\n')
2807  CalFile.write('chb_A1Entry.insert(4, ' + str(CHB_A1.get()) + ')\n')
2808  CalFile.write('chb_A2Entry.delete(0,END)\n')
2809  CalFile.write('chb_A2Entry.insert(4, ' + str(CHB_A2.get()) + ')\n')
2810 
2811  CalFile.close()
2812 
2813 def BLoadCal():
2814  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
2815  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
2816  global DevID
2817  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
2818  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
2819  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
2820  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
2821 
2822  devidstr = DevID[17:31]
2823  filename = devidstr + "_O.cal"
2824  try:
2825  CalFile = open(filename)
2826  for line in CalFile:
2827  exec( line.rstrip() )
2828  CalFile.close()
2829  except:
2830  print( "Cal file for this device not found")
2831 
2832 def BUserAMeas():
2833  global UserAString, UserALabel, MeasUserA
2834 
2835  TempString = UserALabel
2836  UserALabel = askstring("Measurement Label", "Current Label: " + UserALabel + "\n\nNew Label:\n", initialvalue=UserALabel)
2837  if (UserALabel == None): # If Cancel pressed, then None
2838  MeasUserA.set(0)
2839  UserALabel = TempString
2840  return
2841  TempString = UserAString
2842  UserAString = askstring("Measurement Formula", "Current Formula: " + UserAString + "\n\nNew Formula:\n", initialvalue=UserAString)
2843  if (UserAString == None): # If Cancel pressed, then None
2844  MeasUserA.set(0)
2845  UserAString = TempString
2846  return
2847  MeasUserA.set(1)
2848 
2849 def BUserBMeas():
2850  global UserBString, UserBLabel, MeasUserB
2851 
2852  TempString = UserBLabel
2853  UserBLabel = askstring("Measurement Label", "Current Label: " + UserBLabel + "\n\nNew Label:\n", initialvalue=UserBLabel)
2854  if (UserBLabel == None): # If Cancel pressed, then None
2855  MeasUserB.set(0)
2856  UserBLabel = TempString
2857  return
2858  TempString = UserBString
2859  UserBString = askstring("Measurement Formula", "Current Formula: " + UserBString + "\n\nNew Formula:\n", initialvalue=UserBString)
2860  if (UserBString == None): # If Cancel pressed, then None
2861  MeasUserB.set(0)
2862  UserBString = TempString
2863  return
2864  MeasUserB.set(1)
2865 #
2866 
2867 def BUserCustomPlotText():
2868  global LabelPlotText, PlotLabelText # = "Custom Plot Label"
2869 
2870  TempString = PlotLabelText
2871  PlotLabelText = askstring("Custom Label", "Current Plot Label: " + PlotLabelText + "\n\nNew Label:\n", initialvalue=PlotLabelText)
2872  if (PlotLabelText == None): # If Cancel pressed, then None
2873  LabelPlotText.set(0)
2874  PlotLabelText = TempString
2875  return
2876  LabelPlotText.set(1)
2877 
2878 def NewEnterMathControls():
2879  global RUNstatus, MathScreenStatus, MathWindow, SWRev, RevDate
2880  global MathString, MathUnits, MathXString, MathXUnits, MathYString, MathYUnits
2881  global MathAxis, MathXAxis, MathYAxis, MathTrace
2882  global formentry, unitsentry, axisentry, xformentry, xunitsentry, xaxisentry, yformentry, yunitsentry, yaxisentry
2883  global formlab, xformlab, yformlab, FrameBG
2884  global Mframe1, Mframe2, Mframe3, Mframe4
2885 
2886  if MathScreenStatus.get() == 0:
2887  MathScreenStatus.set(1)
2888  #
2889  MathWindow = Toplevel()
2890  MathWindow.title("Math Formula " + SWRev + RevDate)
2891  MathWindow.resizable(FALSE,FALSE)
2892  MathWindow.protocol("WM_DELETE_WINDOW", DestroyMathScreen)
2893  MathWindow.configure(background=FrameBG)
2894  Mframe1 = LabelFrame(MathWindow, text="Built-in Exp", style="A10T5.TLabelframe") #"A10T5.TLabelframe")
2895  Mframe2 = LabelFrame(MathWindow, text="Math Trace", style="A10T5.TLabelframe")
2896  Mframe3 = LabelFrame(MathWindow, text="X Math Trace", style="A10T6.TLabelframe")
2897  Mframe4 = LabelFrame(MathWindow, text="Y Math Trace", style="A10T7.TLabelframe")
2898  # frame1.grid(row=0, column=0, sticky=W)
2899  #
2900  Mframe1.grid(row = 0, column=0, rowspan=3, sticky=W)
2901  Mframe2.grid(row = 0, column=1, sticky=W)
2902  Mframe3.grid(row = 1, column=1, sticky=W)
2903  Mframe4.grid(row = 2, column=1, sticky=W)
2904  #
2905  # Built in functions
2906  #
2907  mrb1 = Radiobutton(Mframe1, text='none', variable=MathTrace, value=0, command=UpdateTimeTrace)
2908  mrb1.grid(row=0, column=0, sticky=W)
2909  mrb2 = Radiobutton(Mframe1, text='CAV+CBV', variable=MathTrace, value=1, command=UpdateTimeTrace)
2910  mrb2.grid(row=1, column=0, sticky=W)
2911  mrb3 = Radiobutton(Mframe1, text='CAV-CBV', variable=MathTrace, value=2, command=UpdateTimeTrace)
2912  mrb3.grid(row=2, column=0, sticky=W)
2913  mrb4 = Radiobutton(Mframe1, text='CBV-CAV', variable=MathTrace, value=3, command=UpdateTimeTrace)
2914  mrb4.grid(row=3, column=0, sticky=W)
2915  mrb5 = Radiobutton(Mframe1, text='CAI-CBI', variable=MathTrace, value=8, command=UpdateTimeTrace)
2916  mrb5.grid(row=4, column=0, sticky=W)
2917  mrb6 = Radiobutton(Mframe1, text='CBI-CAI', variable=MathTrace, value=9, command=UpdateTimeTrace)
2918  mrb6.grid(row=5, column=0, sticky=W)
2919  mrb7 = Radiobutton(Mframe1, text='CAV*CAI', variable=MathTrace, value=4, command=UpdateTimeTrace)
2920  mrb7.grid(row=6, column=0, sticky=W)
2921  mrb8 = Radiobutton(Mframe1, text='CBV*CBI', variable=MathTrace, value=5, command=UpdateTimeTrace)
2922  mrb8.grid(row=7, column=0, sticky=W)
2923  mrb9 = Radiobutton(Mframe1, text='CAV/CAI', variable=MathTrace, value=6, command=UpdateTimeTrace)
2924  mrb9.grid(row=8, column=0, sticky=W)
2925  mrb10 = Radiobutton(Mframe1, text='CBV/CBI', variable=MathTrace, value=7, command=UpdateTimeTrace)
2926  mrb10.grid(row=9, column=0, sticky=W)
2927  mrb11 = Radiobutton(Mframe1, text='CBV/CAV', variable=MathTrace, value=10, command=UpdateTimeTrace)
2928  mrb11.grid(row=10, column=0, sticky=W)
2929  mrb12 = Radiobutton(Mframe1, text='CBI/CAI', variable=MathTrace, value=11, command=UpdateTimeTrace)
2930  mrb12.grid(row=11, column=0, sticky=W)
2931  mrb13 = Radiobutton(Mframe1, text='Formula', variable=MathTrace, value=12, command=UpdateTimeTrace)
2932  mrb13.grid(row=12, column=0, sticky=W)
2933  #
2934  # Math trace formula sub Mframe2
2935  #
2936  sframe2a = Frame( Mframe2 )
2937  sframe2a.pack(side=TOP)
2938  formlab = Label(sframe2a, text=" Formula ", style= "A10B.TLabel")
2939  formlab.pack(side=LEFT)
2940  formentry = Entry(sframe2a, width=23)
2941  formentry.pack(side=LEFT)
2942  formentry.delete(0,"end")
2943  formentry.insert(0,MathString)
2944  sframe2b = Frame( Mframe2 )
2945  sframe2b.pack(side=TOP)
2946  unitslab = Label(sframe2b, text="Units ", style= "A10B.TLabel")
2947  unitslab.pack(side=LEFT)
2948  unitsentry = Entry(sframe2b, width=6)
2949  unitsentry.pack(side=LEFT)
2950  unitsentry.delete(0,"end")
2951  unitsentry.insert(0,MathUnits)
2952  checkbt = Button(sframe2b, text="Check", command=CheckMathString )
2953  checkbt.pack(side=LEFT)
2954  sframe2c = Frame( Mframe2 )
2955  sframe2c.pack(side=TOP)
2956  axislab = Label(sframe2c, text="Axis ", style= "A10B.TLabel")
2957  axislab.pack(side=LEFT)
2958  axisentry = Entry(sframe2c, width=4)
2959  axisentry.pack(side=LEFT)
2960  axisentry.delete(0,"end")
2961  axisentry.insert(0,MathAxis)
2962  applybt = Button(sframe2c, text="Apply", command=ApplyMathString )
2963  applybt.pack(side=LEFT)
2964  #
2965  # X Math trace formula sub Mframe3
2966  #
2967  sframe3a = Frame( Mframe3 )
2968  sframe3a.pack(side=TOP)
2969  xformlab = Label(sframe3a, text="X Formula ", style= "A10B.TLabel")
2970  xformlab.pack(side=LEFT)
2971  xformentry = Entry(sframe3a, width=23)
2972  xformentry.pack(side=LEFT)
2973  xformentry.delete(0,"end")
2974  xformentry.insert(0, MathXString)
2975  sframe3b = Frame( Mframe3 )
2976  sframe3b.pack(side=TOP)
2977  xunitslab = Label(sframe3b, text="X Units ", style= "A10B.TLabel")
2978  xunitslab.pack(side=LEFT)
2979  xunitsentry = Entry(sframe3b, width=6)
2980  xunitsentry.pack(side=LEFT)
2981  xunitsentry.delete(0,"end")
2982  xunitsentry.insert(0, MathXUnits)
2983  xcheckbt = Button(sframe3b, text="Check", command=CheckMathXString )
2984  xcheckbt.pack(side=LEFT)
2985  sframe3c = Frame( Mframe3 )
2986  sframe3c.pack(side=TOP)
2987  xaxislab = Label(sframe3c, text="X Axis ", style= "A10B.TLabel")
2988  xaxislab.pack(side=LEFT)
2989  xaxisentry = Entry(sframe3c, width=4)
2990  xaxisentry.pack(side=LEFT)
2991  xaxisentry.delete(0,"end")
2992  xaxisentry.insert(0, MathXAxis)
2993  xapplybt = Button(sframe3c, text="Apply", command=ApplyMathXString )
2994  xapplybt.pack(side=LEFT)
2995  #
2996  # Math trace formula sub Mframe4
2997  #
2998  sframe4a = Frame( Mframe4 )
2999  sframe4a.pack(side=TOP)
3000  yformlab = Label(sframe4a, text="Y Formula ", style= "A10B.TLabel")
3001  yformlab.pack(side=LEFT)
3002  yformentry = Entry(sframe4a, width=23)
3003  yformentry.pack(side=LEFT)
3004  yformentry.delete(0,"end")
3005  yformentry.insert(0,MathYString)
3006  sframe4b = Frame( Mframe4 )
3007  sframe4b.pack(side=TOP)
3008  yunitslab = Label(sframe4b, text="Y Units ", style= "A10B.TLabel")
3009  yunitslab.pack(side=LEFT)
3010  yunitsentry = Entry(sframe4b, width=6)
3011  yunitsentry.pack(side=LEFT)
3012  yunitsentry.delete(0,"end")
3013  yunitsentry.insert(0,MathYUnits)
3014  ycheckbt = Button(sframe4b, text="Check", command=CheckMathYString )
3015  ycheckbt.pack(side=LEFT)
3016  sframe4c = Frame( Mframe4 )
3017  sframe4c.pack(side=TOP)
3018  yaxislab = Label(sframe4c, text="Y Axis ", style= "A10B.TLabel")
3019  yaxislab.pack(side=LEFT)
3020  yaxisentry = Entry(sframe4c, width=4)
3021  yaxisentry.pack(side=LEFT)
3022  yaxisentry.delete(0,"end")
3023  yaxisentry.insert(0,MathYAxis)
3024  yapplybt = Button(sframe4c, text="Apply", command=ApplyMathYString )
3025  yapplybt.pack(side=LEFT)
3026 
3027  dismissbutton = Button(MathWindow, text="Dismiss", command=DestroyMathScreen)
3028  dismissbutton.grid(row=3, column=0, sticky=W)
3029 
3030  if RUNstatus.get() > 0:
3031  UpdateTimeTrace()
3032 
3033 def DestroyMathScreen():
3034  global MathScreenStatus, MathWindow
3035 
3036  if MathScreenStatus.get() == 1:
3037  MathScreenStatus.set(0)
3038  MathWindow.destroy()
3039 
3040 def CheckMathString():
3041  global MathString, formentry, MathUnits, unitsentry, MathAxis, axisentry, formlab
3042  global VBuffA, VBuffB, IBuffA, IBuffB
3043  global VBuffMA, VBuffMB, VBuffMC, VBuffMD
3044  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
3045  global VUnAvgA, VUnAvgB, IUnAvgA, IUnAvgB, UnAvgSav
3046  global FFTBuffA, FFTBuffB, FFTwindowshape
3047  global AWGAwaveform, AWGBwaveform
3048  global Show_MathX, Show_MathY
3049  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
3050  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
3051 
3052  t = 0
3053  TempString = formentry.get()
3054  try:
3055  MathResult = eval(TempString)
3056  formlab.configure(text="Formula ", style= "A10G.TLabel")
3057  except:
3058  formlab.configure(text="Formula ", style= "A10R.TLabel")
3059 
3060 def CheckMathXString():
3061  global MathXString, xformentry, MathXUnits, xunitsentry, MathXAxis, xaxisentry, xformlab
3062  global VBuffA, VBuffB, IBuffA, IBuffB
3063  global VBuffMA, VBuffMB, VBuffMC, VBuffMD
3064  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
3065  global VUnAvgA, VUnAvgB, IUnAvgA, IUnAvgB, UnAvgSav
3066  global FFTBuffA, FFTBuffB, FFTwindowshape
3067  global AWGAwaveform, AWGBwaveform
3068  global Show_MathX, Show_MathY
3069  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
3070  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
3071 
3072  t = 0
3073  TempString = xformentry.get()
3074  try:
3075  MathResult = eval(TempString)
3076  xformlab.configure(text="X Formula ", style= "A10G.TLabel")
3077  except:
3078  xformlab.configure(text="X Formula ", style= "A10R.TLabel")
3079 
3080 def CheckMathYString():
3081  global MathYString, yformentry, MathYUnits, yunitsentry, MathYAxis, yaxisentry, yformlab
3082  global VBuffA, VBuffB, IBuffA, IBuffB
3083  global VBuffMA, VBuffMB, VBuffMC, VBuffMD
3084  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
3085  global VUnAvgA, VUnAvgB, IUnAvgA, IUnAvgB, UnAvgSav
3086  global FFTBuffA, FFTBuffB, FFTwindowshape
3087  global AWGAwaveform, AWGBwaveform
3088  global Show_MathX, Show_MathY
3089  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
3090  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
3091 
3092  t = 0
3093  TempString = yformentry.get()
3094  try:
3095  MathResult = eval(TempString)
3096  yformlab.configure(text="Y Formula ", style= "A10G.TLabel")
3097  except:
3098  yformlab.configure(text="Y Formula ", style= "A10R.TLabel")
3099 
3100 def ApplyMathString():
3101  global MathString, formentry, MathUnits, unitsentry, MathAxis, axisentry
3102 
3103  MathString = formentry.get()
3104  MathUnits = unitsentry.get()
3105  MathAxis = axisentry.get()
3106 
3107 def ApplyMathXString():
3108  global MathXString, xformentry, MathXUnits, xunitsentry, MathXAxis, xaxisentry
3109 
3110  MathXString = xformentry.get()
3111  MathXUnits = xunitsentry.get()
3112  MathXAxis = xaxisentry.get()
3113 
3114 def ApplyMathYString():
3115  global MathYString, yformentry, MathYUnits, yunitsentry, MathYAxis, yaxisentry
3116 
3117  MathYString = yformentry.get()
3118  MathYUnits = yunitsentry.get()
3119  MathYAxis = yaxisentry.get()
3120 
3121 def BSetMarkerLocation():
3122  global MarkerLoc, RUNstatus
3123 
3124  TempString = MarkerLoc
3125  MarkerLoc = askstring("Marker Text Location", "Current Marker Text Location: " + MarkerLoc + "\n\nNew Location: (UL, UR, LL, LR)\n", initialvalue=MarkerLoc)
3126  if (MarkerLoc == None): # If Cancel pressed, then None
3127  MarkerLoc = TempString
3128  if RUNstatus.get() == 0: # if not running
3129  UpdateTimeTrace() # Update
3130 
3131 def donothing():
3132  global RUNstatus
3133 
3134 def DoNothing(event):
3135  global RUNstatus
3136 
3137 def BShowCurvesAll():
3138  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, RUNstatus
3139 
3140  ShowC1_V.set(1)
3141  ShowC1_I.set(1)
3142  ShowC2_V.set(1)
3143  ShowC2_I.set(1)
3144  if RUNstatus.get() == 0: # if not running
3145  UpdateTimeTrace() # Update
3146 
3147 def BShowCurvesNone():
3148  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, RUNstatus
3149 
3150  ShowC1_V.set(0)
3151  ShowC1_I.set(0)
3152  ShowC2_V.set(0)
3153  ShowC2_I.set(0)
3154  if RUNstatus.get() == 0: # if not running
3155  UpdateTimeTrace() # Update
3156 
3157 def BTriggerEdge():
3158  global TgEdge
3159 
3160 # TRIGCOND trigcondRisingPositive = 0
3161 # TRIGCOND trigcondFallingNegative = 1
3162 
3163 def BTrigger50p():
3164  global TgInput, TRIGGERlevel, TRIGGERentry, RUNstatus
3165  global MaxV1, MinV1, MaxV2, MinV2
3166  global MaxI1, MinI1, MaxI2, MinI2
3167  global MidVMuxA, MidVMuxB, MidVMuxC, MidVMuxD
3168  global ChopMuxMode, ChopTrig
3169  # set new trigger level to mid point of waveform
3170  MidV1 = (MaxV1+MinV1)/2
3171  MidV2 = (MaxV2+MinV2)/2
3172  MidI1 = (MaxI1+MinI1)/2
3173  MidI2 = (MaxI2+MinI2)/2
3174  if (TgInput.get() == 0):
3175  DCString = "0.0"
3176  elif (TgInput.get() == 1 or TgInput.get() == 5):
3177  DCString = ' {0:.2f} '.format(MidV1)
3178  elif (TgInput.get() == 2 ):
3179  DCString = ' {0:.2f} '.format(MidI1)
3180  elif (TgInput.get() == 3 ):
3181  DCString = ' {0:.2f} '.format(MidV2)
3182  elif (TgInput.get() == 4 ):
3183  DCString = ' {0:.2f} '.format(MidI2)
3184 #
3185  if ChopMuxMode.get() > 0:
3186  if ChopTrig.get() == 0:
3187  DCString = "0.0"
3188  if ChopTrig.get() == 1:
3189  DCString = ' {0:.2f} '.format(MidVMuxA)
3190  if ChopTrig.get() == 2:
3191  DCString = ' {0:.2f} '.format(MidVMuxB)
3192  if ChopTrig.get() == 3:
3193  DCString = ' {0:.2f} '.format(MidVMuxC)
3194  if ChopTrig.get() == 4:
3195  DCString = ' {0:.2f} '.format(MidVMuxD)
3196 #
3197  TRIGGERlevel = eval(DCString)
3198  TRIGGERentry.delete(0,END)
3199  TRIGGERentry.insert(4, DCString)
3200  if RUNstatus.get() == 0: # if not running
3201  UpdateTimeTrace() # Update
3202 
3203 
3204 def BTriggerMode():
3205  global TgInput
3206 
3207 # if (TgInput.get() == 0):
3208  # no trigger
3209 # elif (TgInput.get() == 1):
3210  # trigger source set to detector of analog in channels
3211  # auto trigger timeout value
3212 # elif (TgInput.get() == 2):
3213  # trigger source set to detector of analog in channels
3214  # 0 disables auto trigger
3215 
3216 def BTriglevel(event):
3217  global TRIGGERlevel, TRIGGERentry, RUNstatus
3218 
3219  # evalute entry string to a numerical value
3220  try:
3221  TRIGGERlevel = float(eval(TRIGGERentry.get()))
3222  except:
3223  TRIGGERentry.delete(0,END)
3224  TRIGGERentry.insert(0, TRIGGERlevel)
3225  # set new trigger level
3226  if RUNstatus.get() == 0: # if not running
3227  UpdateTimeTrace() # Update
3228 
3229 
3230 def BHoldOff(event):
3231  global HoldOff, HoldOffentry, RUNstatus
3232 
3233  try:
3234  HoldOff = float(eval(HoldOffentry.get()))
3235  except:
3236  HoldOffentry.delete(0,END)
3237  HoldOffentry.insert(0, HoldOff)
3238  if RUNstatus.get() == 0: # if not running
3239  UpdateTimeTrace() # Update
3240 # Set Horx possition from entry widget
3241 def BHozPoss(event):
3242  global HozPoss, HozPossentry, RUNstatus
3243 
3244  try:
3245  HozPoss = float(eval(HozPossentry.get()))
3246  except:
3247  HozPossentry.delete(0,END)
3248  HozPossentry.insert(0, HozPoss)
3249  if RUNstatus.get() == 0: # if not running
3250  UpdateTimeTrace() # Update
3251 #
3252 def SetTriggerPoss():
3253  global HozPossentry, TgInput, TMsb
3254 
3255  # get time scale
3256  try:
3257  TIMEdiv = float(eval(TMsb.get()))
3258  except:
3259  TIMEdiv = 0.5
3260  TMsb.delete(0,"end")
3261  TMsb.insert(0,TIMEdiv)
3262  # prevent divide by zero error
3263  if TIMEdiv < 0.0002:
3264  TIMEdiv = 0.01
3265  if TgInput.get() > 0:
3266  HozPoss = -5 * TIMEdiv
3267  HozPossentry.delete(0,END)
3268  HozPossentry.insert(0, HozPoss)
3269 #
3270 def IncHoldOff():
3271  global HoldOffentry, HoldOff, TgInput, TMsb
3272 
3273 # get time scale
3274  try:
3275  TIMEdiv = float(eval(TMsb.get()))
3276  except:
3277  TIMEdiv = 0.5
3278  TMsb.delete(0,"end")
3279  TMsb.insert(0,TIMEdiv)
3280  # prevent divide by zero error
3281  if TIMEdiv < 0.0002:
3282  TIMEdiv = 0.01
3283  if TgInput.get() == 0:
3284  HoldOff = HoldOff + TIMEdiv
3285  HoldOffentry.delete(0,END)
3286  HoldOffentry.insert(0, HoldOff)
3287 
3288 def SetMuxAPoss():
3289  global CHB_APosEntry, DCVMuxA
3290 
3291  CHB_APosEntry.delete(0,"end")
3292  CHB_APosEntry.insert(0, ' {0:.2f} '.format(DCVMuxA))
3293 #
3294 def SetMuxBPoss():
3295  global CHB_BPosEntry, DCVMuxB
3296 
3297  CHB_BPosEntry.delete(0,"end")
3298  CHB_BPosEntry.insert(0, ' {0:.2f} '.format(DCVMuxB))
3299 #
3300 def SetMuxCPoss():
3301  global CHB_CPosEntry, DCVMuxC
3302 
3303  CHB_CPosEntry.delete(0,"end")
3304  CHB_CPosEntry.insert(0, ' {0:.2f} '.format(DCVMuxC))
3305 #
3306 def SetMuxDPoss():
3307  global CHD_BPosEntry, DCVMuxD
3308 
3309  CHB_DPosEntry.delete(0,"end")
3310  CHB_DPosEntry.insert(0, ' {0:.2f} '.format(DCVMuxD))
3311 #
3312 def SetScaleMuxA():
3313  global MarkerScale, CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab
3314 
3315  if MarkerScale.get() != 1:
3316  MarkerScale.set(5)
3317  CHB_Alab.config(style="Rtrace2.TButton")
3318  CHB_Blab.config(style="Strace6.TButton")
3319  CHB_Clab.config(style="Strace7.TButton")
3320  CHB_Dlab.config(style="Strace4.TButton")
3321  else:
3322  MarkerScale.set(0)
3323 #
3324 def SetScaleMuxB():
3325  global MarkerScale, CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab
3326 
3327  if MarkerScale.get() != 1:
3328  MarkerScale.set(6)
3329  CHB_Alab.config(style="Strace2.TButton")
3330  CHB_Blab.config(style="Rtrace6.TButton")
3331  CHB_Clab.config(style="Strace7.TButton")
3332  CHB_Dlab.config(style="Strace4.TButton")
3333  else:
3334  MarkerScale.set(0)
3335 #
3336 def SetScaleMuxC():
3337  global MarkerScale, CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab
3338 
3339  if MarkerScale.get() != 1:
3340  MarkerScale.set(7)
3341  CHB_Alab.config(style="Strace2.TButton")
3342  CHB_Blab.config(style="Strace6.TButton")
3343  CHB_Clab.config(style="Rtrace7.TButton")
3344  CHB_Dlab.config(style="Strace4.TButton")
3345  else:
3346  MarkerScale.set(0)
3347 #
3348 def SetScaleMuxD():
3349  global MarkerScale, CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab
3350 
3351  if MarkerScale.get() != 1:
3352  MarkerScale.set(8)
3353  CHB_Alab.config(style="Strace2.TButton")
3354  CHB_Blab.config(style="Strace6.TButton")
3355  CHB_Clab.config(style="Strace7.TButton")
3356  CHB_Dlab.config(style="Rtrace4.TButton")
3357  else:
3358  MarkerScale.set(0)
3359 #
3360 def SetVAPoss():
3361  global CHAVPosEntry, DCV1
3362 
3363  CHAVPosEntry.delete(0,"end")
3364  CHAVPosEntry.insert(0, ' {0:.2f} '.format(DCV1))
3365 #
3366 def SetVBPoss():
3367  global CHBVPosEntry, DCV2
3368 
3369  CHBVPosEntry.delete(0,"end")
3370  CHBVPosEntry.insert(0, ' {0:.2f} '.format(DCV2))
3371 #
3372 def SetIAPoss():
3373  global CHAIPosEntry, DCI1
3374 
3375  CHAIPosEntry.delete(0,"end")
3376  CHAIPosEntry.insert(0, ' {0:.2f} '.format(DCI1))
3377 #
3378 def SetIBPoss():
3379  global CHBIPosEntry, DCI2
3380 
3381  CHBIPosEntry.delete(0,"end")
3382  CHBIPosEntry.insert(0, ' {0:.2f} '.format(DCI2))
3383 #
3384 def SetXYVAPoss():
3385  global CHAVPosEntryxy, DCV1
3386 
3387  CHAVPosEntryxy.delete(0,"end")
3388  CHAVPosEntryxy.insert(0, ' {0:.2f} '.format(DCV1))
3389 #
3390 def SetXYVBPoss():
3391  global CHBVPosEntryxy, DCV2
3392 
3393  CHBVPosEntryxy.delete(0,"end")
3394  CHBVPosEntryxy.insert(0, ' {0:.2f} '.format(DCV2))
3395 #
3396 def SetXYIAPoss():
3397  global CHAIPosEntryxy, DCI1
3398 
3399  CHAIPosEntryxy.delete(0,"end")
3400  CHAIPosEntryxy.insert(0, ' {0:.2f} '.format(DCI1))
3401 #
3402 def SetXYIBPoss():
3403  global CHBIPosEntryxy, DCI2
3404 
3405  CHBIPosEntryxy.delete(0,"end")
3406  CHBIPosEntryxy.insert(0, ' {0:.2f} '.format(DCI2))
3407 
3408 def Bcloseexit():
3409  global RUNstatus, session, CHA, CHB, devx, AWG_2X, Closed
3410 
3411  RUNstatus.set(0)
3412  Closed = 1
3413  # BSaveConfig("alice-last-config.cfg")
3414  try:
3415  # try to write last config file, Don't crash if running in Write protected space
3416  BSaveConfig("alice-last-config.cfg")
3417  # Put channels in Hi-Z and exit
3418  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
3419  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
3420  devx.set_adc_mux(0) # set ADC mux conf to default
3421  AWG_2X.set(0)
3422  BAWG2X()
3423  CHA.constant(0.0)
3424  CHB.constant(0.0)
3425  devx.set_led(0b001) # Set LED.red on the way out
3426  if session.continuous:
3427  session.end()
3428  except:
3429  donothing()
3430 
3431  root.destroy()
3432  exit()
3433 
3434 def BStart():
3435  global RUNstatus, PowerStatus, devx, PwrBt, DevID, FWRevOne, session, AWGSync
3436  global contloop, discontloop, TIMEdiv, First_Slow_sweep
3437  global TimeDisp, XYDisp, PhADisp, FreqDisp, BodeDisp, IADisp
3438 
3439  if DevID == "No Device":
3440  showwarning("WARNING","No Device Plugged In!")
3441  elif FWRevOne == 0.0:
3442  showwarning("WARNING","Out of data Firmware!")
3443  elif TimeDisp.get() == 0 and XYDisp.get() == 0 and PhADisp.get() == 0 and FreqDisp.get() == 0 and BodeDisp.get() == 0 and IADisp.get() == 0:
3444  showwarning("WARNING","Enable at least one Instrument!")
3445  else:
3446  if PowerStatus == 0:
3447  PowerStatus = 1
3448  PwrBt.config(style="Pwr.TButton",text="PWR-On")
3449  devx.ctrl_transfer( 0x40, 0x51, 49, 0, 0, 0, 100) # turn on analog power
3450  if (RUNstatus.get() == 0):
3451  RUNstatus.set(1)
3452  if AWGSync.get() == 0:
3453  session.flush()
3454  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z mode
3455  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z mode
3456  BAWGEnab()
3457  if not session.continuous:
3458  session.start(0)
3459  time.sleep(0.02) # wait awhile here for some reason
3460  elif session.continuous:
3461  session.end()
3462  session.flush()
3463  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z mode
3464  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z mode
3465 
3477  BAWGEnab()
3478  else:
3479  contloop = 0
3480  discontloop = 1
3481  if session.continuous:
3482  session.end() # end continuous session mode
3483 
3484  # UpdateTimeScreen() # Always Update
3485  if TIMEdiv >= 100:
3486  First_Slow_sweep = 0
3487  else:
3488  First_Slow_sweep = 1
3489 #$ Start running Ohmmeter tool
3490 def BStartOhm():
3491  global session, AWGSync
3492 
3493  AWGSync.set(1)
3494  if AWGSync.get() == 0:
3495  session.flush()
3496  if not session.continuous:
3497  session.start(0)
3498  time.sleep(0.02) # wait awhile here for some reason
3499  elif session.continuous:
3500  session.end()
3501  session.flush()
3502  else:
3503  contloop = 0
3504  discontloop = 1
3505  if session.continuous:
3506  session.end() # end continuous session mode
3507 
3508 def BStartIA():
3509  global AWGAFreqEntry, AWGAFreqvalue, Two_X_Sample, FWRevOne, NetworkScreenStatus, BodeDisp
3510 
3511  try:
3512  AWGAFreqvalue = float(eval(AWGAFreqEntry.get()))
3513  except:
3514  AWGAFreqEntry.delete(0,"end")
3515  AWGAFreqEntry.insert(0, AWGAFreqvalue)
3516  if FWRevOne > 2.16:
3517  if AWGAFreqvalue > 10000.0:
3518  Two_X_Sample.set(1)
3519  else:
3520  Two_X_Sample.set(0)
3521  SetADC_Mux()
3522  IASourceSet()
3523  if NetworkScreenStatus.get() > 0 and BodeDisp.get() > 0:
3524  BStartBP()
3525  else:
3526  BStart()
3527 
3528 def IASourceSet():
3529  global IASource, CHA, CHB, AWGAMode, AWGBMode, AWGBIOMode, AWGSync
3530 
3531  if AWGSync.get() == 0: # running in continuous mode
3532  AWGSync.set(1)
3533  if IASource.get() == 1:
3534  CHA.mode = Mode.HI_Z # Put CHA in Hi Z split mode
3535  CHB.mode = Mode.HI_Z # Put CHB in Hi Z split mode
3536  AWGAMode.set(2) # Set AWG A to Hi-Z
3537  else:
3538  CHA.mode = Mode.SVMI # Put CHA in Hi Z split mode
3539  CHB.mode = Mode.HI_Z # Put CHB in Hi Z split mode
3540  AWGAMode.set(0) # Set AWG A to SVMI
3541  if AWGBIOMode.get() == 0: # if not in split I/O mode
3542  AWGBMode.set(2) # Set AWG B to Hi-Z
3543 
3544 def BStop():
3545  global RUNstatus, TimeDisp, XYDisp, FreqDisp, IADisp, session, AWGSync
3546  global CHA, CHB, contloop, discontloop
3547 
3548  if (RUNstatus.get() == 1):
3549  # print("Stoping")
3550  RUNstatus.set(0)
3551  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
3552  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
3553  if AWGSync.get() == 0: # running in continuous mode
3554  CHA.constant(0.0)
3555  CHB.constant(0.0)
3556  # print("Stoping continuous mode")
3557  # session.cancel() # cancel continuous session mode while paused
3558  if session.continuous:
3559  #print( "Is Continuous? ", session.continuous)
3560  session.end()
3561  #time.sleep(0.02)
3562  #print( "Is Continuous? ", session.continuous)
3563  else:
3564  contloop = 0
3565  discontloop = 1
3566  session.cancel()
3567 #
3568  if TimeDisp.get() > 0:
3569  UpdateTimeScreen() # Always Update screens as necessary
3570  if XYDisp.get() > 0:
3571  UpdateXYScreen()
3572  if FreqDisp.get() > 0:
3574  if IADisp.get() > 0:
3575  UpdateIAScreen()
3576 
3577 def BPower():
3578  global RUNstatus, PowerStatus, devx, PwrBt
3579 
3580  if (RUNstatus.get() == 1):
3581  BStop()
3582  if PowerStatus == 1:
3583  PowerStatus = 0
3584  PwrBt.config(style="PwrOff.TButton",text="PWR-Off")
3585  devx.ctrl_transfer( 0x40, 0x50, 49, 0, 0, 0, 100) # turn off analog power
3586  else:
3587  PowerStatus = 1
3588  PwrBt.config(style="Pwr.TButton",text="PWR-On")
3589  devx.ctrl_transfer( 0x40, 0x51, 49, 0, 0, 0, 100) # turn on analog power
3590 
3591 def BRoll():
3592  global Roll_Mode, RollBt
3593 
3594  if Roll_Mode.get() == 1:
3595  Roll_Mode.set(0)
3596  RollBt.config(style="RollOff.TButton",text="Roll-Off")
3597  else:
3598  Roll_Mode.set(1)
3599  RollBt.config(style="Roll.TButton",text="Roll-On")
3600 
3601 
3602 def BTime():
3603  global TIMEdiv, TMsb, RUNstatus, Two_X_Sample, ETSDisp, FWRevOne, ChopMuxMode
3604  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, AWGSync
3605 
3606  try: # get time scale in mSec/div
3607  TIMEdiv = float(eval(TMsb.get()))
3608  if TIMEdiv < 0.0002:
3609  TIMEdiv = 0.01
3610  TMsb.delete(0,"end")
3611  TMsb.insert(0,TIMEdiv)
3612  except:
3613  TIMEdiv = 0.5
3614  TMsb.delete(0,"end")
3615  TMsb.insert(0,TIMEdiv)
3616  # Switch to 2X sampleling if time scale small enough and not runing ETS
3617  # and not in analog input mux Chop mode.
3618  if ETSDisp.get() == 0 and ChopMuxMode.get() == 0:
3619  Samples_per_div = TIMEdiv * 100.0 # samples per mSec @ base sample rate
3620  if FWRevOne > 2.16:
3621  if Samples_per_div < 20.0:
3622  NumTraces = ShowC1_V.get() + ShowC1_I.get() + ShowC2_V.get() + ShowC2_I.get()
3623  if NumTraces > 2 and AWGSync.get() == 0:
3624  showwarning("WARNING","You need to Select only 2 Traces or Enable AWG Sync Mode!")
3625  BStop()
3626  Two_X_Sample.set(1)
3628  else:
3629  Two_X_Sample.set(0)
3630  SetADC_Mux()
3631  #
3632  if RUNstatus.get() == 0: # if not running
3633  UpdateTimeTrace() # Update
3634 
3635 def BCHAlevel():
3636  global CHAsb, RUNstatus, CH1vpdvLevel
3637 
3638  try:
3639  CH1vpdvLevel = float(eval(CHAsb.get()))
3640  except:
3641  CHAsb.delete(0,END)
3642  CHAsb.insert(0, CH1vpdvLevel)
3643  if RUNstatus.get() == 0:
3644  UpdateTimeTrace() # if not running Update
3645 
3646 def BCHAIlevel():
3647  global CHAIsb, RUNstatus, CH1ipdvLevel
3648 
3649  try:
3650  CH1ipdvLevel = float(eval(CHAIsb.get()))
3651  except:
3652  CHAIsb.delete(0,END)
3653  CHAIsb.insert(0, CH1ipdvLevel)
3654  if RUNstatus.get() == 0:
3655  UpdateTimeTrace() # if not running Update
3656 
3657 def BCHBlevel():
3658  global CHBsb, RUNstatus, CH2vpdvLevel
3659 
3660  try:
3661  CH2vpdvLevel = float(eval(CHBsb.get()))
3662  except:
3663  CHBsb.delete(0,END)
3664  CHBsb.insert(0, CH2vpdvLevel)
3665  if RUNstatus.get() == 0:
3666  UpdateTimeTrace() # if not running Update
3667 
3668 def BCHBIlevel():
3669  global CHBIsb, RUNstatus, CH2ipdvLevel
3670 
3671  try:
3672  CH2ipdvLevel = float(eval(CHBIsb.get()))
3673  except:
3674  CHBIsb.delete(0,END)
3675  CHBIsb.insert(0, CH2ipdvLevel)
3676  if RUNstatus.get() == 0:
3677  UpdateTimeTrace() # if not running Update
3678 
3679 def BOffsetA(event):
3680  global CHAOffset, CHAVPosEntry, RUNstatus
3681 
3682  try:
3683  CHAOffset = float(eval(CHAVPosEntry.get())) # evalute entry string to a numerical value
3684  except:
3685  CHAVPosEntry.delete(0,END)
3686  CHAVPosEntry.insert(0, CHAOffset)
3687  # set new offset level
3688  if RUNstatus.get() == 0:
3689  UpdateTimeTrace() # if not running Update
3690 
3691 def BIOffsetA(event):
3692  global CHAIOffset, CHAIPosEntry, RUNstatus
3693 
3694  try:
3695  CHAIOffset = float(eval(CHAIPosEntry.get())) # evalute entry string to a numerical value
3696  except:
3697  CHAIPosEntry.delete(0,END)
3698  CHAIPosEntry.insert(0, CHAIOffset)
3699  # set new offset level
3700  if RUNstatus.get() == 0:
3701  UpdateTimeTrace() # if not running Update
3702 
3703 def BOffsetB(event):
3704  global CHBOffset, CHBVPosEntry, RUNstatus
3705 
3706  try:
3707  CHBOffset = float(eval(CHBVPosEntry.get())) # evalute entry string to a numerical value
3708  except:
3709  CHBVPosEntry.delete(0,END)
3710  CHBVPosEntry.insert(0, CHBOffset)
3711  # set new offset level
3712  if RUNstatus.get() == 0:
3713  UpdateTimeTrace() # if not running Update
3714 
3715 def BIOffsetB(event):
3716  global CHBIOffset, CHBIPosEntry, RUNstatus
3717 
3718  try:
3719  CHBIOffset = float(eval(CHBIPosEntry.get())) # evalute entry string to a numerical value
3720  except:
3721  CHBIPosEntry.delete(0,END)
3722  CHBIPosEntry.insert(0, CHBIOffset)
3723  # set new offset level
3724  if RUNstatus.get() == 0:
3725  UpdateTimeTrace() # if not running Update
3726 
3727 def TimeCheckBox():
3728  global TimeDisp, ckb1
3729  if TimeDisp.get() == 1:
3730  ckb1.config(style="Enab.TCheckbutton")
3731  else:
3732  ckb1.config(style="Disab.TCheckbutton")
3733 #
3734 def XYCheckBox():
3735  global XYDisp, ckb2
3736  if XYDisp.get() == 1:
3737  ckb2.config(style="Enab.TCheckbutton")
3738  else:
3739  ckb2.config(style="Disab.TCheckbutton")
3740 #
3741 def FreqCheckBox():
3742  global FreqDisp, ckb3, OOTckb3, OOTScreenStatus
3743  if FreqDisp.get() == 1:
3744  if OOTScreenStatus.get() == 0:
3745  ckb3.config(style="Enab.TCheckbutton")
3746  else:
3747  OOTckb3.config(style="Enab.TCheckbutton")
3748  else:
3749  if OOTScreenStatus.get() == 0:
3750  ckb3.config(style="Disab.TCheckbutton")
3751  else:
3752  OOTckb3.config(style="Disab.TCheckbutton")
3753 #
3754 def BodeCheckBox():
3755  global BodeDisp, ckb5, AWGSync, OOTckb5, OOTScreenStatus
3756  if BodeDisp.get() == 1:
3757  AWGSync.set(1)
3758  if OOTScreenStatus.get() == 0:
3759  ckb5.config(style="Enab.TCheckbutton")
3760  else:
3761  OOTckb5.config(style="Enab.TCheckbutton")
3762  else:
3763  if OOTScreenStatus.get() == 0:
3764  ckb5.config(style="Disab.TCheckbutton")
3765  else:
3766  OOTckb5.config(style="Disab.TCheckbutton")
3767 #
3768 def IACheckBox():
3769  global IADisp, ckb4, OOTckb4, OOTScreenStatus
3770  if IADisp.get() == 1:
3771  if OOTScreenStatus.get() == 0:
3772  ckb4.config(style="Enab.TCheckbutton")
3773  else:
3774  OOTckb4.config(style="Enab.TCheckbutton")
3775  else:
3776  if OOTScreenStatus.get() == 0:
3777  ckb4.config(style="Disab.TCheckbutton")
3778  else:
3779  OOTckb4.config(style="Disab.TCheckbutton")
3780 #
3781 def PhACheckBox():
3782  global PhADisp, Phckb, OOTphckb, OOTScreenStatus
3783  if PhADisp.get() == 1:
3784  if OOTScreenStatus.get() == 0:
3785  phckb.config(style="Enab.TCheckbutton")
3786  else:
3787  OOTphckb.config(style="Enab.TCheckbutton")
3788  else:
3789  if OOTScreenStatus.get() == 0:
3790  phckb.config(style="Disab.TCheckbutton")
3791  else:
3792  OOTphckb.config(style="Disab.TCheckbutton")
3793 #
3794 def OhmCheckBox():
3795  global OhmDisp, ckb6, OOTckb6, OOTScreenStatus
3796  if OhmDisp.get() == 1:
3797  if OOTScreenStatus.get() == 0:
3798  ckb6.config(style="Enab.TCheckbutton")
3799  else:
3800  OOTckb6.config(style="Enab.TCheckbutton")
3801  else:
3802  if OOTScreenStatus.get() == 0:
3803  ckb6.config(style="Disab.TCheckbutton")
3804  else:
3805  OOTckb6.config(style="Disab.TCheckbutton")
3806 #
3807 def ETSCheckBox():
3808  global ETSDisp, enb1
3809  if ETSDisp.get() == 1:
3810  enb1.config(style="Enab.TCheckbutton")
3811  else:
3812  try:
3813  enb1.config(style="Disab.TCheckbutton")
3814  except:
3815  donothing()
3816 # ========================= Main routine ====================================
3817 
3818 def Analog_In():
3819  global RUNstatus, SingleShot, ManualTrigger, TimeDisp, XYDisp, FreqDisp, SpectrumScreenStatus, HWRevOne
3820  global PhADisp, IADisp, IAScreenStatus, CutDC, DevOne, AWGBMode, MuxEnb, BodeScreenStatus, BodeDisp
3821  global MuxScreenStatus, VBuffA, VBuffB, MuxSync, AWGBIOMode
3822  global VmemoryMuxA, VmemoryMuxB, VmemoryMuxC, VmemoryMuxD, MuxChan
3823  global ShowC1_V, ShowC2_V, ShowC2_I, SMPfft
3824  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
3825  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
3826  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
3827  global SV1, SI1, SV2, SI2, SVA_B, Closed
3828  global FregPoint, FBins, FStep, TRACEaverage
3829  # Analog Mux channel measurement variables
3830  global TRACEresetTime, TRACEmodeTime, TgInput, SettingsStatus, TRIGGERsample
3831  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, DualMuxMode, ChopMuxMode
3832  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
3833  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
3834  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
3835  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
3836  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
3837 
3838  while (Closed == 0): # Main loop
3839  # RUNstatus = 1 : Open Acquisition
3840  if (RUNstatus.get() == 1) or (RUNstatus.get() == 2):
3841  if SettingsStatus.get() == 1:
3842  SettingsUpdate() # Make sure current entries in Settings controls are up to date
3843  if TimeDisp.get() > 0 or XYDisp.get() > 0 or PhADisp.get() > 0:
3844  if MuxScreenStatus.get() == 0:
3845  MuxChan = -1
3846  Analog_Time_In()
3847  else:
3848  MuxChan = 0
3849  if DualMuxMode.get() == 1: # force split I/O mode if dual mux mode set
3850  AWGAIOMode.set(1)
3851  AWGBIOMode.set(1)
3852  ShowC1_V.set(0) # force A voltage trace off
3853  ShowC2_V.set(0) # force B voltage trace off
3854  if HWRevOne == "D" :
3855  # force channel B to always be in High-Z mode for Rev D hardware or if not in split I/O mode
3856  AWGBMode.set(2)
3857  if AWGBIOMode.get() == 0: # if not in split I/O mode
3858  ShowC2_I.set(0) # no need to show CH-B current
3859  if MuxEnb.get() == 1:
3860  PIO2 = 0x51
3861  else:
3862  PIO2 = 0x50
3863  if MuxSync.get() == 0:
3864  PIO3 = 0x51
3865  PIO3x = 0x50
3866  else:
3867  PIO3 = 0x50
3868  PIO3x = 0x51
3869  #
3870  if ChopMuxMode.get() == 0: # do this if in alternate sweep mode
3871  if TRACEmodeTime.get() == 0 and TRACEresetTime == False:
3872  TRACEresetTime = True # Clear the memory for averaging
3873  if Show_CBA.get() == 1:
3874  MuxChan = 0
3875  devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 to 0
3876  devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 1 to 0
3877  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO enable
3878  devx.ctrl_transfer(0x40, PIO3, PIO_3, 0, 0, 0, 100) # set PIO 3 to 1 sync pulse for sweep start
3879  time.sleep(0.002)
3880  devx.ctrl_transfer(0x40, PIO3x, PIO_3, 0, 0, 0, 100) # set PIO 3 to return value
3881  if TRACEmodeTime.get() == 1:
3882  if TRACEresetTime == True:
3883  TRACEresetTime = False
3884  # Save previous trace in memory for average trace
3885  VmemoryMuxA = VBuffMA
3886  Analog_Time_In()
3887  if Show_CBB.get() == 1:
3888  MuxChan = 1
3889  devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0 to 1
3890  devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 1 to 0
3891  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO 2 to 0
3892  devx.ctrl_transfer(0x40, PIO3, PIO_3, 0, 0, 0, 100) # set PIO 3 to sync pulse for sweep start
3893  time.sleep(0.002)
3894  devx.ctrl_transfer(0x40, PIO3x, 3, 0, 0, 0, 100) # set PIO 3 to return value
3895  if TRACEmodeTime.get() == 1:
3896  if TRACEresetTime == True:
3897  TRACEresetTime = False
3898  # Save previous trace in memory for average trace
3899  VmemoryMuxB = VBuffMB
3900  Analog_Time_In()
3901  if Show_CBC.get() == 1:
3902  MuxChan = 2
3903  if DualMuxMode.get() == 1:
3904  devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0 to 1
3905  devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 1 to 0
3906  else:
3907  devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 to 0
3908  devx.ctrl_transfer(0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 1 to 1
3909  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO 2 to 0
3910  devx.ctrl_transfer(0x40, PIO3, PIO_3, 0, 0, 0, 100) # set PIO 3 to sync pulse for sweep start
3911  time.sleep(0.002)
3912  devx.ctrl_transfer(0x40, PIO3x, PIO_3, 0, 0, 0, 100) # set PIO 3 to return value
3913  if TRACEmodeTime.get() == 1:
3914  if TRACEresetTime == True:
3915  TRACEresetTime = False
3916  # Save previous trace in memory for average trace
3917  VmemoryMuxC = VBuffMC
3918  Analog_Time_In()
3919  if Show_CBD.get() == 1:
3920  MuxChan = 3
3921  if DualMuxMode.get() == 1:
3922  devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 to 0
3923  devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 1 to 0
3924  else:
3925  devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0 to 1
3926  devx.ctrl_transfer(0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 1 to 1
3927  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO 2 to 0
3928  devx.ctrl_transfer(0x40, PIO3, PIO_3, 0, 0, 0, 100) # set PIO 3 to sync pulse for sweep start
3929  time.sleep(0.002)
3930  devx.ctrl_transfer(0x40, PIO3x, PIO_3, 0, 0, 0, 100) # set PIO 3 to return value
3931  if TRACEmodeTime.get() == 1:
3932  if TRACEresetTime == True:
3933  TRACEresetTime = False
3934  # Save previous trace in memory for average trace
3935  VmemoryMuxD = VBuffMD
3936  Analog_Time_In()
3937  if Show_CBA.get() == 0 and Show_CBB.get() == 0 and Show_CBC.get() == 0 and Show_CBD.get() == 0 and ShowC1_V.get() == 1:
3938  Analog_Time_In()
3939  else: # do this if in Chop mode
3940  MuxChan = 0
3941  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO_2 enable control
3942  if TRACEmodeTime.get() == 0 and TRACEresetTime == False:
3943  TRACEresetTime = True # Clear the memory for averaging
3944  elif TRACEmodeTime.get() == 1:
3945  if TRACEresetTime == True:
3946  TRACEresetTime = False
3947  # Save previous traces in memory for average trace
3948  VmemoryMuxA = VBuffMA
3949  VmemoryMuxB = VBuffMB
3950  VmemoryMuxC = VBuffMC
3951  VmemoryMuxD = VBuffMD
3952  Analog_Time_In()
3953  if (FreqDisp.get() > 0 and SpectrumScreenStatus.get() == 1) or (IADisp.get() > 0 and IAScreenStatus.get() == 1) or (BodeDisp.get() > 0 and BodeScreenStatus.get() == 1):
3954  if IADisp.get() > 0 or BodeDisp.get() > 0:
3955  CutDC.set(1) # remove DC portion of waveform
3956  AWGSync.set(1) # Impedance analyzer and Bode plotter must be run in discontinuous mode
3957  if BodeDisp.get() > 0:
3958  if LoopNum.get() <= len(FStep):
3959  FregPoint = FBins[int(FStep[LoopNum.get()-1])] # look up next frequency from list of bins
3960  if FregPoint <= 5.0:
3961  SMPfft = 32768*2
3962  elif FregPoint <= 10.0:
3963  SMPfft = 32768
3964  elif FregPoint < 100.0:
3965  SMPfft = 16384
3966  elif FregPoint < 500.0:
3967  SMPfft = 8192
3968  elif FregPoint < 2000.0:
3969  SMPfft = 4096
3970  else:
3971  SMPfft = 2048
3972  if Two_X_Sample.get() > 0 and FregPoint < 2000.0:
3973  SMPfft = SMPfft * 2
3974 
3975  Analog_Freq_In()
3976  elif OhmRunStatus.get() == 1 and OhmDisp.get() == 1:
3977  Ohm_Analog_In()
3978  else:
3979  time.sleep(0.01) # slow down loop while not running to reduce CPU usage
3980  root.update_idletasks()
3981  root.update()
3982 
3983 def Ohm_Analog_In():
3984  global RMode, CHATestVEntry, CHATestREntry, CHA, CHB, devx, OhmA0, OhmA1, discontloop
3985  global AWGAMode, AWGBMode, AWGAShape, AWGSync, AWGBTerm, AWGAOffsetEntry
3986  global AWGAIOMode, AWGBIOMode, Two_X_Sample
3987 
3988 # Do input probe Calibration CH1VGain, CH2VGain, CH1VOffset, CH2VOffset
3989  try:
3990  InOffA = float(eval(CHAVOffsetEntry.get()))
3991  except:
3992  CHAVOffsetEntry.delete(0,END)
3993  CHAVOffsetEntry.insert(0, InOffA)
3994  try:
3995  InGainA = float(eval(CHAVGainEntry.get()))
3996  except:
3997  CHAVGainEntry.delete(0,END)
3998  CHAVGainEntry.insert(0, InGainA)
3999  try:
4000  InOffB = float(eval(CHBVOffsetEntry.get()))
4001  except:
4002  CHBVOffsetEntry.delete(0,END)
4003  CHBVOffsetEntry.insert(0, InOffB)
4004  try:
4005  InGainB = float(eval(CHBVGainEntry.get()))
4006  except:
4007  CHBVGainEntry.delete(0,END)
4008  CHBVGainEntry.insert(0, InGainB)
4009  try:
4010  CurOffA = float(CHAIOffsetEntry.get())
4011  except:
4012  CurOffA = 0.0
4013  try:
4014  CurOffB = float(CHBIOffsetEntry.get())
4015  except:
4016  CurOffB = 0.0
4017  try:
4018  CurGainA = float(CHAIGainEntry.get())
4019  except:
4020  CurGainA = 1.0
4021  try:
4022  CurGainB = float(CHBIGainEntry.get())
4023  except:
4024  CurGainB = 1.0
4025  try:
4026  chatestv = float(eval(CHATestVEntry.get()))
4027  if chatestv > 5.0:
4028  chatestv = 5.0
4029  CHATestVEntry.delete(0,END)
4030  CHATestVEntry.insert(0, chatestv)
4031  except:
4032  CHATestVEntry.delete(0,END)
4033  CHATestVEntry.insert(0, chatestv)
4034  try:
4035  chatestr = float(eval(CHATestREntry.get()))
4036  except:
4037  CHATestREntry.delete(0,END)
4038  CHATestREntry.insert(0, chatestr)
4039  #
4040  DCVA0 = DCVB0 = DCIA0 = DCIB0 = 0.0 # initalize measurment variable
4041  RIN = 1000000 # nominal ALM1000 input resistance is 1 Mohm
4042  Two_X_Sample.set(0) # make sure we are in 1V sample rate mode
4043  SetADC_Mux()
4044  # set A and B channels
4045  AWGAMode.set(0) # Set AWG A to SVMI
4046  AWGAShape.set(0) # DC
4047  AWGBMode.set(2) # Set AWG B to Hi-Z
4048  AWGAIOMode.set(0) # turn off Split I/O mode
4049  AWGBIOMode.set(0) # turn off Split I/O mode
4050  AWGAOffsetEntry.delete(0,"end")
4051  AWGAOffsetEntry.insert(0, chatestv)
4052  BAWGAModeLabel()
4053  BAWGBModeLabel() # update AWG labels
4054 
4055  if RMode.get() == 0:
4056  AWGBTerm.set(0)
4057  else:
4058  AWGBTerm.set(1)
4059  #
4060  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
4061  if discontloop > 0:
4062  session.flush()
4063  else:
4064  discontloop = 1
4065  time.sleep(0.01)
4066  BAWGEnab()
4067  ADsignal1 = devx.get_samples(210) # get samples for both channel A and B
4068  # time.sleep(1000.0/SHOWsamples)
4069  else: # running in continuous mode
4070  if session.continuous:
4071  ADsignal1 = devx.read(210, -1, True) # get samples for both channel A and B
4072  #
4073  # get_samples returns a list of values for voltage [0] and current [1]
4074  for index in range(200): # calculate average
4075  DCVA0 += ADsignal1[index+10][0][0] # VAdata # Sum for average CA voltage
4076  DCVB0 += ADsignal1[index+10][1][0] # VBdata # Sum for average CB voltage
4077  DCIA0 += ADsignal1[index+10][0][1] # Sum for average CA current
4078  DCIB0 += ADsignal1[index+10][1][1] # Sum for average CB current
4079 
4080  DCVA0 = DCVA0 / 200.0 # calculate average
4081  DCVB0 = DCVB0 / 200.0 # calculate average
4082  DCIA0 = DCIA0 / 200.0 # calculate average
4083  DCIB0 = DCIB0 / 200.0 # calculate average
4084  DCVA0 = (DCVA0 - InOffA) * InGainA
4085  DCVB0 = (DCVB0 - InOffB) * InGainB
4086  DCIA0 = ((DCIA0*1000) - CurOffA) * CurGainA
4087  DCIB0 = ((DCIB0*1000) - CurOffB) * CurGainB
4088  if RMode.get() == 0: # external resistor
4089  DCM = chatestr * (DCVB0/(DCVA0-DCVB0))
4090  DCR = (DCM * RIN) / (RIN - DCM) # correct for channel B input resistance
4091  else: # use internal 50 ohm resistor
4092  DCR = chatestr * ((DCVA0-DCVB0)/DCVB0)
4093  if DCR < 1000:
4094  OhmString = '{0:.2f} '.format(DCR) + "Ohms "# format with 2 decimal places
4095  else:
4096  OhmString = '{0:.3f} '.format(DCR/1000) + "KOhms " # divide by 1000 and format with 3 decimal places
4097  IAString = "Meas " + ' {0:.2f} '.format(DCIA0) + " mA " + ' {0:.2f} '.format(DCVB0) + " V"
4098  OhmA0.config(text = OhmString) # change displayed value
4099  OhmA1.config(text = IAString) # change displayed value
4100 #
4101  time.sleep(0.1)
4102  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
4103 
4105 def Analog_Time_In():
4106  global TIMEdiv, TMsb, TRACEmodeTime, TRACEresetTime, TRACEaverage
4107  global VBuffMA, VmemoryMuxA, VBuffMB, VmemoryMuxB, VBuffMC, VmemoryMuxC, VBuffMD, VmemoryMuxD
4108  global CHAVOffsetEntry, CHAVGainEntry, CHBVOffsetEntry, CHBVGainEntry
4109  global CHAIOffsetEntry, CHBIOffsetEntry, CHAIGainEntry, CHBIGainEntry
4110  global InOffA, InGainA, InOffB, InGainB
4111  global CurOffA, CurOffB, CurGainA, CurGainB
4112  global PhADisp, PhAScreenStatus, MuxScreenStatus, ChopMuxMode
4113  global First_Slow_sweep, Roll_Mode
4114  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
4115 
4116  # get time scale
4117  try:
4118  TIMEdiv = eval(TMsb.get())
4119  except:
4120  TIMEdiv = 0.5
4121  TMsb.delete(0,"end")
4122  TMsb.insert(0,TIMEdiv)
4123  if TIMEdiv < 0.0002:
4124  TIMEdiv = 0.01
4125  #
4126 # Do input divider Calibration CH1VGain, CH2VGain, CH1VOffset, CH2VOffset
4127  try:
4128  InOffA = float(eval(CHAVOffsetEntry.get()))
4129  except:
4130  CHAVOffsetEntry.delete(0,END)
4131  CHAVOffsetEntry.insert(0, InOffA)
4132  try:
4133  InGainA = float(eval(CHAVGainEntry.get()))
4134  except:
4135  CHAVGainEntry.delete(0,END)
4136  CHAVGainEntry.insert(0, InGainA)
4137  try:
4138  InOffB = float(eval(CHBVOffsetEntry.get()))
4139  except:
4140  CHBVOffsetEntry.delete(0,END)
4141  CHBVOffsetEntry.insert(0, InOffB)
4142  try:
4143  InGainB = float(eval(CHBVGainEntry.get()))
4144  except:
4145  CHBVGainEntry.delete(0,END)
4146  CHBVGainEntry.insert(0, InGainB)
4147  try:
4148  CurOffA = float(CHAIOffsetEntry.get()) #/1000.0 # convert to Amps # leave in mA
4149  except:
4150  CurOffA = 0.0
4151  try:
4152  CurOffB = float(CHBIOffsetEntry.get())#/1000.0 # convert to Amps
4153  except:
4154  CurOffB = 0.0
4155  try:
4156  CurGainA = float(CHAIGainEntry.get())
4157  except:
4158  CurGainA = 1.0
4159  try:
4160  CurGainB = float(CHBIGainEntry.get())
4161  except:
4162  CurGainB = 1.0
4163 # Dedecide which Fast or Slow sweep routine to call
4164  if Roll_Mode.get() > 0: # 200:
4165  Analog_Roll_time() # rolling trace
4166  else:
4167  First_Slow_sweep = 0
4169 #
4170  if PhADisp.get() > 0 and PhAScreenStatus.get() == 1:
4171  Analog_Phase_In()
4172 #
4173 # Process captured time dmain signals to extract magnitude and phase data
4174 def Analog_Phase_In():
4175  global ADsignal1, VBuffA, VBuffB, IBuffA, IBuffB
4176  global VBuffMA, VBuffMB, VBuffMC, VBuffMD
4177  global VAresult, VBresult, IAresult, IBresult, VABresult, IABresult
4178  global PhaseVA, PhaseVB, PhaseIA, PhaseIB, PhaseVAB, PhaseIAB
4179  global VMAresult, VMBresult,VMCresult, VMDresult
4180  global PhaseVMA, PhaseVMB, PhaseVMC, PhaseVMD
4181  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
4182  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
4183  global DCVMuxA, DCVMuxB, DCVMuxC, DCVMuxD
4184  global SHOWsamples, SMPfft, hldn, MuxScreenStatus, MuxChan, ChopMuxMode
4185  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D
4186  global FFTwindowshape, ZEROstuffing
4187 
4188  if len(VBuffA) < SMPfft: # put up warning to reduce number of FFT Samples or increase Time/Div time base
4190  #showwarning("WARNING","Redude Number of Samples \n Or Increas Time/Div time base.")
4191  #BStop() # Force Stop loop if running
4192  #return
4193  # Do an FFT on captured voltage and current buffer
4194  StartSmp = hldn
4195  StopSmp = hldn + SMPfft
4197  REX = []
4198  PhaseVA = []
4199  PhaseIA = []
4200  PhaseIB = []
4201  PhaseIAB = []
4202  # Convert list to numpy array REX for faster Numpy calculations
4203  # Take the first SMPfft samples of VBuffA
4204  REX = numpy.array(VBuffA[StartSmp:StopSmp]-DCV1) # Make a numpy arry of the list
4205 
4206  # Set Analog level display value MAX value is 5 volts for ALM1000
4207  REX = REX / 5.0
4208 
4209  # Do the FFT window function
4210  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
4211  # FFT with numpy
4212  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
4213  PhaseVA = numpy.angle(ALL, deg=True) # calculate angle
4214  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
4215 
4216  le = int(len(ALL) / 2) # Only half is used, other half is mirror
4217  ALL = ALL[0:le] # So take only first half of the array
4218  PhaseVA = PhaseVA[0:le]
4219  Totalcorr = 7.07106 / SMPfft # RMS For VOLTAGE!
4220  VAresult = Totalcorr * ALL
4221  # check to see if analog Mux is being used?
4222  if MuxScreenStatus.get() == 0:
4223  PhaseVB = []
4224  PhaseVAB = []
4225  # Now VB array
4226  REX = numpy.array(VBuffB[StartSmp:StopSmp]-DCV2) # Make a numpy arry of the list
4227 
4228  # Set Analog level display value MAX value is 5 volts for ALM1000
4229  REX = REX / 5.0
4230 
4231  # Do the FFT window function
4232  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
4233 
4234  # FFT with numpy
4235  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
4236  PhaseVB = numpy.angle(ALL, deg=True) # calculate angle
4237  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
4238 
4239  le = int(len(ALL) / 2) # Only half is used, other half is mirror
4240  ALL = ALL[0:le] # So take only first half of the array
4241  PhaseVB = PhaseVB[0:le]
4242  RMScorr = 7.07106 / SMPfft # For rMS VOLTAGE!
4243  VBresult = RMScorr * ALL
4244 
4245  # Now VAB array
4246  REX = numpy.array(VBuffA[StartSmp:StopSmp]-VBuffB[StartSmp:StopSmp]) # Make a numpy arry of the list
4247  REX = REX - (DCV1-DCV2) # cut any remaining DC
4248  # Set Analog level display value MAX value is 5 volts for ALM1000
4249  REX = REX / 5.0
4250 
4251  # Do the FFT window function
4252  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
4253 
4254  # FFT with numpy
4255  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
4256  PhaseVAB = numpy.angle(ALL, deg=True) # calculate angle
4257  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
4258 
4259  le = int(len(ALL) / 2) # Only half is used, other half is mirror
4260  ALL = ALL[0:le] # So take only first half of the array
4261  PhaseVAB = PhaseVAB[0:le]
4262  RMScorr = 7.07106 / SMPfft # For rms VOLTAGE!
4263  VABresult = RMScorr * ALL
4264  else: # Do FFTs on Mux buffers as needed if MuxScreenStatus.get() > 0:
4265  if MuxChan == 0 or ChopMuxMode.get() > 0: #
4266  PhaseVMA = []
4267  # Now VMuxA array
4268  REX = numpy.array(VBuffMA[StartSmp:StopSmp]-DCVMuxA) # Make a numpy arry of the list
4269 
4270  # Set Analog level display value MAX value is 5 volts for ALM1000
4271  REX = REX / 5.0
4272 
4273  # Do the FFT window function
4274  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
4275 
4276  # FFT with numpy
4277  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
4278  PhaseVMA = numpy.angle(ALL, deg=True) # calculate angle
4279  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
4280 
4281  le = int(len(ALL) / 2) # Only half is used, other half is mirror
4282  ALL = ALL[0:le] # So take only first half of the array
4283  PhaseVMA = PhaseVMA[0:le]
4284  RMScorr = 7.07106 / SMPfft # For rms VOLTAGE!
4285  VMAresult = RMScorr * ALL
4286  if MuxChan == 1 or ChopMuxMode.get() > 0: # MuxChan = 1
4287  PhaseVMB = []
4288  # Now VMuxA array
4289  REX = numpy.array(VBuffMB[StartSmp:StopSmp]-DCVMuxB) # Make a numpy arry of the list
4290 
4291  # Set Analog level display value MAX value is 5 volts for ALM1000
4292  REX = REX / 5.0
4293 
4294  # Do the FFT window function
4295  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
4296 
4297  # FFT with numpy
4298  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
4299  PhaseVMB = numpy.angle(ALL, deg=True) # calculate angle
4300  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
4301 
4302  le = int(len(ALL) / 2) # Only half is used, other half is mirror
4303  ALL = ALL[0:le] # So take only first half of the array
4304  PhaseVMB = PhaseVMB[0:le]
4305  RMScorr = 7.07106 / SMPfft # For rms VOLTAGE!
4306  VMBresult = RMScorr * ALL
4307  if MuxChan == 2 or ChopMuxMode.get() > 0: # MuxChan = 2
4308  PhaseVMC = []
4309  # Now VMuxA array
4310  REX = numpy.array(VBuffMC[StartSmp:StopSmp]-DCVMuxC) # Make a numpy arry of the list
4311 
4312  # Set Analog level display value MAX value is 5 volts for ALM1000
4313  REX = REX / 5.0
4314 
4315  # Do the FFT window function
4316  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
4317 
4318  # FFT with numpy
4319  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
4320  PhaseVMC = numpy.angle(ALL, deg=True) # calculate angle
4321  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
4322 
4323  le = int(len(ALL) / 2) # Only half is used, other half is mirror
4324  ALL = ALL[0:le] # So take only first half of the array
4325  PhaseVMC = PhaseVMC[0:le]
4326  RMScorr = 7.07106 / SMPfft # For rms VOLTAGE!
4327  VMCresult = RMScorr * ALL
4328  if MuxChan == 3 or ChopMuxMode.get() > 0: # MuxChan = 3
4329  PhaseVMD = []
4330  # Now VMuxA array
4331  REX = numpy.array(VBuffMD[StartSmp:StopSmp]-DCVMuxD) # Make a numpy arry of the list
4332 
4333  # Set Analog level display value MAX value is 5 volts for ALM1000
4334  REX = REX / 5.0
4335 
4336  # Do the FFT window function
4337  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
4338 
4339  # FFT with numpy
4340  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
4341  PhaseVMD = numpy.angle(ALL, deg=True) # calculate angle
4342  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
4343 
4344  le = int(len(ALL) / 2) # Only half is used, other half is mirror
4345  ALL = ALL[0:le] # So take only first half of the array
4346  PhaseVMD = PhaseVMD[0:le]
4347  RMScorr = 7.07106 / SMPfft # For rms VOLTAGE!
4348  VMDresult = RMScorr * ALL
4349  # Now IA array
4350  REX = numpy.array(IBuffA[StartSmp:StopSmp]-DCI1) # Make a numpy arry of the list
4351 
4352  # Set Analog level display value MAX value is 0.2 amps for ALM1000
4353  REX = REX / 0.5
4354 
4355  # Do the FFT window function
4356  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
4357 
4358  # FFT with numpy
4359  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
4360  PhaseIA = numpy.angle(ALL, deg=True) # calculate angle
4361  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
4362 
4363  le = int(len(ALL) / 2) # Only half is used, other half is mirror
4364  ALL = ALL[0:le] # So take only first half of the array
4365  PhaseIA = PhaseIA[0:le]
4366  RMScorr = 0.707106 / SMPfft # RMS For current!
4367  IAresult = RMScorr * ALL
4368 
4369  # Now IB array
4370  REX = numpy.array(IBuffB[StartSmp:StopSmp]-DCI2) # Make a numpy arry of the list
4371 
4372  # Set Analog level display value MAX value is 0.2 amps for ALM1000
4373  REX = REX / 0.5
4374 
4375  # Do the FFT window function
4376  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
4377 
4378  # FFT with numpy
4379  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
4380  PhaseIB = numpy.angle(ALL, deg=True) # calculate angle
4381  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
4382 
4383  le = int(len(ALL) / 2) # Only half is used, other half is mirror
4384  ALL = ALL[0:le] # So take only first half of the array
4385  PhaseIB = PhaseIB[0:le]
4386  RMScorr = 0.707106 / SMPfft # RMS For current!
4387  IBresult = RMScorr * ALL
4388  # Now IA+B array
4389  IDC = DCI1 + DCI2
4390  REX = numpy.array(IBuffA[StartSmp:StopSmp]+IBuffB[StartSmp:StopSmp]) # -DCI1 Make a numpy arry of the list
4391  REX = REX - IDC
4392  # Set Analog level display value MAX value is 0.2 amps for ALM1000
4393  REX = REX / 0.5
4394 
4395  # Do the FFT window function
4396  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
4397 
4398  # FFT with numpy
4399  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
4400  PhaseIAB = numpy.angle(ALL, deg=True) # calculate angle
4401  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
4402 
4403  le = int(len(ALL) / 2) # Only half is used, other half is mirror
4404  ALL = ALL[0:le] # So take only first half of the array
4405  PhaseIAB = PhaseIAB[0:le]
4406  RMScorr = 0.707106 / SMPfft # RMS For current!
4407  IABresult = RMScorr * ALL
4408 
4409 #
4410  UpdatePhAAll()
4411 #
4412 # Right now this is a limited attempt to plot rolling sweep.
4413 def Analog_Roll_time():
4414  global ADsignal1, VBuffA, VBuffB, IBuffA, IBuffB, VFilterA, VFilterB
4415  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
4416  global VUnAvgA, VUnAvgB, IUnAvgA, IUnAvgB, UnAvgSav
4417  global DBuff0, DBuff1, DBuff2, DBuff3, D0, D1, D2, D3
4418  global AWGSync, AWGAMode, AWGBMode, TMsb, HoldOff, HoldOffentry, HozPoss, HozPossentry
4419  global AWGAIOMode, AWGBIOMode, DecimateOption, DualMuxMode, MuxChan
4420  global TRACEresetTime, TRACEmodeTime, TRACEaverage, TRIGGERsample, TgInput, LShift
4421  global CHA, CHB, session, devx, discontloop, contloop
4422  global TRACES, TRACESread, TRACEsize, First_Slow_sweep, Roll_Mode # , ShiftPointer
4423  global RUNstatus, SingleShot, ManualTrigger, TimeDisp, XYDisp, FreqDisp
4424  global TIMEdiv1x, TIMEdiv, hldn, Is_Triggered, GRW
4425  global SAMPLErate, SHOWsamples, MinSamples, MaxSamples, AWGSAMPLErate
4426  global TRACErefresh, AWGScreenStatus, XYScreenStatus, MeasureStatus
4427  global SCREENrefresh, DCrefresh
4428  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
4429  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
4430  global SV1, SI1, SV2, SI2, SVA_B
4431  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
4432  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry
4433  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
4434  global InOffA, InGainA, InOffB, InGainB, CurOffA, CurOffB, CurGainA, CurGainB
4435  global DigFiltA, DigFiltB, DFiltACoef, DFiltBCoef, DigBuffA, DigBuffB
4436  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
4437  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
4438  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
4439  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
4440  global VAets, VBets, Samples_Cycle, MulX, ETSDisp, ETSDir, ETSts, Fmin, FminE, eqivsamplerate
4441  global DivXEntry, FOffEntry, FminDisp, FOff, DivX, FMulXEntry, FBase, MaxETSrecord
4442  global cal, Two_X_Sample, ADC_Mux_Mode, Alternate_Sweep_Mode, Last_ADC_Mux_Mode
4443  global MeasGateLeft, MeasGateRight, MeasGateNum, MeasGateStatus
4444  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, DualMuxMode
4445  global VmemoryMuxA, VmemoryMuxB, VmemoryMuxC, VmemoryMuxD
4446  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
4447  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
4448  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
4449  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
4450  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
4451  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
4452 
4453  # Starting acquisition
4454  DCVA0 = DCVB0 = DCIA0 = DCIB0 = 0.0 # initalize measurment variable
4455  #
4456  NumSamples = 10 # int(SAMPLErate/TIMEdiv)
4457  if First_Slow_sweep == 0:
4458  VBuffA = numpy.ones(GRW)
4459  VBuffB = numpy.ones(GRW)
4460  IBuffA = numpy.ones(GRW)
4461  IBuffB = numpy.ones(GRW)
4462  DBuff0 = numpy.ones(GRW)
4463  DBuff1 = numpy.ones(GRW)
4464  DBuff2 = numpy.ones(GRW)
4465  DBuff3 = numpy.ones(GRW)
4466  First_Slow_sweep = 1
4467  if len(VBuffA) != GRW:
4468  VBuffA = numpy.ones(GRW)
4469  VBuffB = numpy.ones(GRW)
4470  IBuffA = numpy.ones(GRW)
4471  IBuffB = numpy.ones(GRW)
4472  DBuff0 = numpy.ones(GRW)
4473  DBuff1 = numpy.ones(GRW)
4474  DBuff2 = numpy.ones(GRW)
4475  DBuff3 = numpy.ones(GRW)
4476  #
4477  if AWGScreenStatus.get() == 1: # don't try to start AWG is AWG screen is closed
4478  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
4479  if discontloop > 0:
4480  session.flush()
4481  else:
4482  discontloop = 1
4483  BAWGEnab()
4484  ADsignal1 = devx.get_samples(NumSamples) # get samples for both channel A and B
4485  # waite to finish then return to open termination
4486  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
4487  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
4488  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
4489  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
4490 
4491  else: # running in continuous mode
4492  if session.continuous:
4493  if MuxScreenStatus.get() > 0:
4494  devx.flush(-1, True)
4495  DummySamples = NumSamples*2
4496  if DummySamples < 10000:
4497  DummySamples = 10000
4498  ADsignal1 = devx.read(DummySamples, -1, True) # do dummy read if in analog mux mode
4499  ADsignal1 = devx.read(NumSamples, -1, True) # True) get samples for both channel A and B
4500  #
4501  else:
4502  ADsignal1 = devx.get_samples(NumSamples) # , True) # get samples for both channel A and B
4503  # get_samples returns a list of values for voltage [0] and current [1]
4504  for index in range(NumSamples): # calculate average
4505  DCVA0 += ADsignal1[index][0][0] # Sum for average CA voltage
4506  DCVB0 += ADsignal1[index][1][0] # Sum for average CB voltage
4507  DCIA0 += ADsignal1[index][0][1] # Sum for average CA current
4508  DCIB0 += ADsignal1[index][1][1] # Sum for average CB current
4509  DCVA0 = DCVA0/(NumSamples) # calculate V average
4510  DCVB0 = DCVB0/(NumSamples) # calculate V average
4511  DCIA0 = DCIA0/(NumSamples) # calculate I average
4512  DCIB0 = DCIB0/(NumSamples) # calculate I average
4513  # Adjust for gain and offset
4514  DCVA0 = (DCVA0 - InOffA) * InGainA
4515  DCVB0 = (DCVB0 - InOffB) * InGainB
4516  DCIA0 = ((DCIA0*1000) - CurOffA) * CurGainA # convert to mA
4517  DCIB0 = ((DCIB0*1000) - CurOffB) * CurGainB # convert to mA
4518 # next new sample
4519  VBuffA = shift_buffer(VBuffA, -1, DCVA0)
4520  VBuffB = shift_buffer(VBuffB, -1, DCVB0)
4521  IBuffA = shift_buffer(IBuffA, -1, DCIA0)
4522  IBuffB = shift_buffer(IBuffB, -1, DCIB0)
4523 # Make digital input buffer if that port is an input
4524  if D0.get() == 0:
4525  DBuff0 = shift_buffer(DBuff0, -1, devx.ctrl_transfer( 0xc0, 0x91, PIO_0, 0, 0, 1, 100))
4526  if D1.get() == 0:
4527  DBuff1 = shift_buffer(DBuff1, -1, devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100))
4528  if D2.get() == 0:
4529  DBuff2 = shift_buffer(DBuff2, -1, devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100))
4530  if D3.get() == 0:
4531  DBuff3 = shift_buffer(DBuff3, -1, devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100))
4532 # Calculate measurement values
4533  SampleEnd = len(VBuffA) - 1
4534  Cal_trace_scalars(0, SampleEnd)
4535 #
4536  if TimeDisp.get() > 0:
4537  MakeTimeTrace() # Update the traces
4538  UpdateTimeScreen() # Update the screen
4539  if XYDisp.get() > 0 and XYScreenStatus.get() > 0:
4540  UpdateXYAll() # Update Data, trace and XY screen
4541  if MeasureStatus.get() > 0:
4543  # update screens
4544 #
4545 def Analog_Chop_Time():
4546  global ADsignal1, VBuffMA, VBuffMB, VBuffMC, VBuffMD
4547  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
4548  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
4549  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
4550  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
4551  global SHOWsamples, ChopModeFilter
4552 
4553  VBuffMA = [] # Clear the Mux A array
4554  VBuffMB = [] # Clear the Mux B array
4555  VBuffMC = [] # Clear the Mux C array
4556  VBuffMD = [] # Clear the Mux D array
4557  index = 1
4558  while index < SHOWsamples-3: # build arrays VBuffMA, VBuffMB, VBuffMC, VBuffMD
4559  pointer = 0
4560  while pointer < 4:
4561  VBuffMA.append(ADsignal1[index+3][0][0]) # chop AIN into Mux A and B
4562  VBuffMB.append(ADsignal1[index+1][0][0])
4563  VBuffMC.append(ADsignal1[index+3][1][0]) # chop BIN into Mux C and D
4564  VBuffMD.append(ADsignal1[index+1][1][0])
4565  pointer = pointer + 1
4566  index = index + 4
4567  VBuffMA = numpy.array(VBuffMA)
4568  VBuffMB = numpy.array(VBuffMB)
4569  VBuffMC = numpy.array(VBuffMC)
4570  VBuffMD = numpy.array(VBuffMD)
4571  # apply a digital filter to interpolate back to 100 KSPS
4572  VBuffMA = numpy.pad(VBuffMA, (4, 0), "edge")
4573  VBuffMA = numpy.convolve(VBuffMA, ChopModeFilter )
4574  VBuffMA = numpy.roll(VBuffMA, -4)
4575  VBuffMB = numpy.pad(VBuffMB, (4, 0), "edge")
4576  VBuffMB = numpy.convolve(VBuffMB, ChopModeFilter)
4577  VBuffMB = numpy.roll(VBuffMB, -6)
4578  VBuffMC = numpy.pad(VBuffMC, (4, 0), "edge")
4579  VBuffMC = numpy.convolve(VBuffMC, ChopModeFilter )
4580  VBuffMC = numpy.roll(VBuffMC, -4)
4581  VBuffMD = numpy.pad(VBuffMD, (4, 0), "edge")
4582  VBuffMD = numpy.convolve(VBuffMD, ChopModeFilter )
4583  VBuffMD = numpy.roll(VBuffMD, -6)
4584  # calculate waveform scalers
4585  EndSample = SHOWsamples-4
4586  DCVMuxA = numpy.mean(VBuffMA[:EndSample])
4587  MinVMuxA = numpy.amin(VBuffMA[:EndSample])
4588  MaxVMuxA = numpy.amax(VBuffMA[:EndSample])
4589  MidVMuxA = (MaxVMuxA+MinVMuxA)/2.0
4590  PPVMuxA = MaxVMuxA-MinVMuxA
4591 #
4592  DCVMuxB = numpy.mean(VBuffMB[:EndSample])
4593  MinVMuxB = numpy.amin(VBuffMB[:EndSample])
4594  MaxVMuxB = numpy.amax(VBuffMB[:EndSample])
4595  MidVMuxB = (MaxVMuxB+MinVMuxB)/2.0
4596  PPVMuxB = MaxVMuxB-MinVMuxB
4597 #
4598  DCVMuxC = numpy.mean(VBuffMC[:EndSample])
4599  MinVMuxC = numpy.amin(VBuffMC[:EndSample])
4600  MaxVMuxC = numpy.amax(VBuffMC[:EndSample])
4601  MidVMuxC = (MaxVMuxC+MinVMuxC)/2.0
4602  PPVMuxC = MaxVMuxC-MinVMuxC
4603 #
4604  DCVMuxD = numpy.mean(VBuffMD[:EndSample])
4605  MinVMuxD = numpy.amin(VBuffMD[:EndSample])
4606  MaxVMuxD = numpy.amax(VBuffMD[:EndSample])
4607  MidVMuxD = (MaxVMuxD+MinVMuxD)/2.0
4608  PPVMuxD = MaxVMuxD-MinVMuxD
4609  # RMS value = square root of average of the data record squared
4610  SVMuxA = numpy.sqrt(numpy.mean(numpy.square(VBuffMA[:EndSample])))
4611  SVMuxB = numpy.sqrt(numpy.mean(numpy.square(VBuffMB[:EndSample])))
4612  SVMuxC = numpy.sqrt(numpy.mean(numpy.square(VBuffMC[:EndSample])))
4613  SVMuxD = numpy.sqrt(numpy.mean(numpy.square(VBuffMD[:EndSample])))
4614 #
4615 # routine for time scales faster than Slow_Sweep_Limit mSec/Div
4616 def Analog_Fast_time():
4617  global ADsignal1, VBuffA, VBuffB, IBuffA, IBuffB, VFilterA, VFilterB
4618  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
4619  global VUnAvgA, VUnAvgB, IUnAvgA, IUnAvgB, UnAvgSav
4620  global AWGSync, AWGAMode, AWGBMode, TMsb, HoldOff, HoldOffentry, HozPoss, HozPossentry
4621  global AWGAIOMode, AWGBIOMode, DecimateOption, DualMuxMode, MuxChan
4622  global TRACEresetTime, TRACEmodeTime, TRACEaverage, TRIGGERsample, TgInput, LShift
4623  global CHA, CHB, session, devx, discontloop, contloop, DeBugMode
4624  global TRACES, TRACESread, TRACEsize, TRIGGERsampleAltA, TRIGGERsampleAltB
4625  global RUNstatus, SingleShot, ManualTrigger, TimeDisp, XYDisp, FreqDisp
4626  global TIMEdiv1x, TIMEdiv, hldn, Is_Triggered, Trigger_LPF_length, LPFTrigger
4627  global SAMPLErate, SHOWsamples, SMPfft, MinSamples, MaxSamples, AWGSAMPLErate
4628  global TRACErefresh, AWGScreenStatus, XYScreenStatus, MeasureStatus
4629  global SCREENrefresh, DCrefresh, ETSrecord
4630  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
4631  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
4632  global SV1, SI1, SV2, SI2, SVA_B
4633  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
4634  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry
4635  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
4636  global InOffA, InGainA, InOffB, InGainB, CurOffA, CurOffB, CurGainA, CurGainB
4637  global DigFiltA, DigFiltB, DFiltACoef, DFiltBCoef, DigBuffA, DigBuffB
4638  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2, CHAI_RC_HP, CHBI_RC_HP
4639  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
4640  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
4641  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
4642  global VAets, VBets, Samples_Cycle, MulX, ETSDisp, ETSDir, ETSts, Fmin, FminE, eqivsamplerate
4643  global DivXEntry, FOffEntry, FminDisp, FOff, DivX, FMulXEntry, FBase, MaxETSrecord
4644  global cal, Two_X_Sample, ADC_Mux_Mode, Alternate_Sweep_Mode, Last_ADC_Mux_Mode
4645  global MeasGateLeft, MeasGateRight, MeasGateNum, MeasGateStatus
4646  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, DualMuxMode, ChopMuxMode, ChopTrig
4647  global VmemoryMuxA, VmemoryMuxB, VmemoryMuxC, VmemoryMuxD
4648  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
4649  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
4650  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
4651  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
4652  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
4653  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
4654  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
4655  global BCASkewEntry, BCBSkewEntry, DigDeSkewA, DigDeSkewB
4656 
4657  if TRACEmodeTime.get() == 0 and TRACEresetTime == False:
4658  TRACEresetTime = True # Clear the memory for averaging
4659  elif TRACEmodeTime.get() == 1:
4660  if TRACEresetTime == True:
4661  TRACEresetTime = False
4662  # Save previous trace in memory for average trace
4663  VmemoryA = VBuffA
4664  VmemoryB = VBuffB
4665  ImemoryA = IBuffA
4666  ImemoryB = IBuffB
4667 
4668  try:
4669  HoldOff = float(eval(HoldOffentry.get()))
4670  if HoldOff < 0:
4671  HoldOff = 0
4672  HoldOffentry.delete(0,END)
4673  HoldOffentry.insert(0, HoldOff)
4674  except:
4675  HoldOffentry.delete(0,END)
4676  HoldOffentry.insert(0, HoldOff)
4677 #
4678  try:
4679  HozPoss = float(eval(HozPossentry.get()))
4680  except:
4681  HozPossentry.delete(0,END)
4682  HozPossentry.insert(0, HozPoss)
4683 
4684  hldn = int(HoldOff * SAMPLErate/1000 )
4685  hozpos = int(HozPoss * SAMPLErate/1000 )
4686  if hozpos < 0:
4687  hozpos = 0
4688  twoscreens = int(SAMPLErate * 20.0 * TIMEdiv / 1000.0) # number of samples to acquire, 2 screen widths
4689  onescreen = int(twoscreens/2)
4690  if hldn+hozpos > MaxSamples-twoscreens:
4691  hldn = MaxSamples-twoscreens-hozpos
4692  HoldOffentry.delete(0,END)
4693  HoldOffentry.insert(0, hldn*1000/SAMPLErate)
4694  if ETSDisp.get() > 0:
4695  if TIMEdiv > 0.2:
4696  MaxETSrecord = int(AWGSAMPLErate * 10 * TIMEdiv / 1000.0)
4697  else:
4698  MaxETSrecord = int(AWGSAMPLErate * 20 * TIMEdiv / 1000.0)
4699  if (MaxETSrecord*100) > MaxSamples:
4700  MaxETSrecord = MaxSamples / 100
4701  try:
4702  DivX = float(eval(DivXEntry.get()))
4703  if DivX < 2:
4704  DivX = 2
4705  if DivX > 75:
4706  DivX = 75
4707  DivXEntry.delete(0,END)
4708  DivXEntry.insert(0, DivX)
4709  except:
4710  DivXEntry.delete(0,END)
4711  DivXEntry.insert(0, DivX)
4712  FOff = 25
4713  MulX = (DivX*SAMPLErate)/(100*FOff)
4714  while MulX > MaxETSrecord:
4715  FOff = FOff + 5
4716  MulX = (DivX*SAMPLErate)/(100*FOff)
4717  FOff = 0 - FOff
4718  if DeBugMode > 0:
4719  SRstring = "Rec Len Mul = " + str(MulX) + " samples"
4720  MulXEntry.config(text = SRstring) # change displayed value
4721  SRstring = "Offset = " + str(FOff) + " samples"
4722  FOffEntry.config(text = SRstring) # change displayed value
4723  SHOWsamples = int(MulX * 100)
4724  else:
4725  SHOWsamples = twoscreens + hldn + hozpos
4726  if SHOWsamples > MaxSamples: # or a Max of 100,000 samples
4727  SHOWsamples = MaxSamples
4728  if SHOWsamples < MinSamples: # or a Min of 1000 samples
4729  SHOWsamples = MinSamples
4730  if PhAScreenStatus.get() > 0:
4731  if SHOWsamples < SMPfft:
4732  SHOWsamples = SMPfft + hldn + hozpos
4733  if hozpos >= 0:
4734  TRIGGERsample = hldn
4735  else:
4736  TRIGGERsample = abs(hozpos)
4737  TRIGGERsample = TRIGGERsample + hozpos #
4738 # Starting acquisition
4739  if AWGScreenStatus.get() == 1: # don't try to start AWG is AWG screen is closed
4740  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
4741  if discontloop > 0:
4742  session.flush()
4743  else:
4744  discontloop = 1
4745  time.sleep(0.01)
4746  BAWGEnab()
4747  ADsignal1 = devx.get_samples(SHOWsamples) # get samples for both channel A and B
4748  # waite to finish then return to open termination
4749  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
4750  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
4751  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
4752  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
4753  else: # running in continuous mode
4754  if session.continuous:
4755  if MuxScreenStatus.get() > 0:
4756  devx.flush(-1, True)
4757  DummySamples = SHOWsamples*2
4758  if DummySamples < 20000:
4759  DummySamples = 20000
4760  ADsignal1 = devx.read(DummySamples, -1, True) # do dummy read if in analog mux mode
4761  ADsignal1 = devx.read(SHOWsamples, -1, True) # get samples for both channel A and B
4762  #
4763  else:
4764  ADsignal1 = devx.get_samples(SHOWsamples) # , True) # get samples for both channel A and B
4765  # waite to finish then return to open termination
4766  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
4767  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
4768  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
4769  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
4770  #
4771  if Alternate_Sweep_Mode.get() == 1 and Two_X_Sample.get() == 1:
4772  if ADC_Mux_Mode.get() == 0: # VA and VB
4773  VBuffA = [] # Clear the V Buff array for trace A
4774  VBuffB = [] # Clear the V Buff array for trace B
4775  elif ADC_Mux_Mode.get() == 1: # IA and IB
4776  IBuffA = [] # Clear the I Buff array for trace A
4777  IBuffB = [] # Clear the I Buff array for trace B
4778  elif ADC_Mux_Mode.get() == 4: # VA and IA
4779  VBuffA = [] # Clear the V Buff array for trace A
4780  IBuffA = [] # Clear the I Buff array for trace A
4781  elif ADC_Mux_Mode.get() == 5: # VB and IB
4782  VBuffB = [] # Clear the V Buff array for trace B
4783  IBuffB = [] # Clear the I Buff array for trace B
4784  else:
4785  VBuffA = [] # Clear the V Buff array for trace A
4786  IBuffA = [] # Clear the I Buff array for trace A
4787  VBuffB = [] # Clear the V Buff array for trace B
4788  IBuffB = [] # Clear the I Buff array for trace B
4789  increment = 1
4790  # SAMPLErate = 200000 #AWGSAMPLErate
4791  if SHOWsamples >= 20000 and DecimateOption.get() > 0:
4792  increment = 2
4793  SAMPLErate = int(AWGSAMPLErate/increment)
4794  if SHOWsamples >= 40000 and DecimateOption.get() > 0:
4795  increment = 4
4796  SAMPLErate = int(AWGSAMPLErate/increment)
4797  index = 0
4798  if SHOWsamples != len(ADsignal1):
4799  SHOWsamples = len(ADsignal1)
4800 #
4801  if ChopMuxMode.get() > 0 and MuxScreenStatus.get() > 0: # check to see if Mux Chop mode is set
4803 #
4804  while index < SHOWsamples: # build arrays and decimate if needed
4805  if Two_X_Sample.get() == 1 and ADC_Mux_Mode.get() < 6:
4806  if ADC_Mux_Mode.get() == 0: # VA and VB
4807  VBuffA.append(ADsignal1[index][0][0])
4808  VBuffA.append(ADsignal1[index][1][1])
4809  VBuffB.append(ADsignal1[index][0][1])
4810  VBuffB.append(ADsignal1[index][1][0])
4811  if Alternate_Sweep_Mode.get() == 0:
4812  IBuffA.append(0.0) # fill as a place holder
4813  IBuffA.append(0.0) # fill as a place holder
4814  IBuffB.append(0.0) # fill as a place holder
4815  IBuffB.append(0.0) # fill as a place holder
4816  elif ADC_Mux_Mode.get() == 1: # IA and IB
4817  IBuffA.append(ADsignal1[index][0][1])
4818  IBuffA.append(ADsignal1[index][1][0])
4819  IBuffB.append(ADsignal1[index][0][0])
4820  IBuffB.append(ADsignal1[index][1][1])
4821  if Alternate_Sweep_Mode.get() == 0:
4822  VBuffA.append(0.0) # fill as a place holder
4823  VBuffA.append(0.0) # fill as a place holder
4824  VBuffB.append(0.0) # fill as a place holder
4825  VBuffB.append(0.0) # fill as a place holder
4826  elif ADC_Mux_Mode.get() == 2: # VA and IB
4827  VBuffA.append((ADsignal1[index][0][1])/1024.0)
4828  VBuffA.append((ADsignal1[index][1][0])/1024.0)
4829  #
4830  IBuffB.append( ((ADsignal1[index][0][0])/4096.0)-0.5 )
4831  IBuffB.append( ((ADsignal1[index][1][1])/4096.0)-0.5 )
4832  #
4833  if Alternate_Sweep_Mode.get() == 0:
4834  VBuffB.append(0.0) # fill as a place holder
4835  VBuffB.append(0.0) # fill as a place holder
4836  IBuffA.append(0.0) # fill as a place holder
4837  IBuffA.append(0.0) # fill as a place holder
4838  elif ADC_Mux_Mode.get() == 3: # VB and IA
4839  VBuffB.append((ADsignal1[index][0][0])/1024.0)
4840  VBuffB.append((ADsignal1[index][1][1])/1024.0)
4841  #
4842  IBuffA.append( ((ADsignal1[index][0][1])/4096.0)-0.5 )
4843  IBuffA.append( ((ADsignal1[index][1][0])/4096.0)-0.5 )
4844  #
4845  if Alternate_Sweep_Mode.get() == 0:
4846  VBuffA.append(0.0) # fill as a place holder
4847  VBuffA.append(0.0) # fill as a place holder
4848  IBuffB.append(0.0) # fill as a place holder
4849  IBuffB.append(0.0) # fill as a place holder
4850  elif ADC_Mux_Mode.get() == 4: # VA and IA
4851  VBuffA.append(ADsignal1[index][0][0])
4852  VBuffA.append(ADsignal1[index][1][1])
4853  IBuffA.append(ADsignal1[index][0][1])
4854  IBuffA.append(ADsignal1[index][1][0])
4855  if Alternate_Sweep_Mode.get() == 0:
4856  VBuffB.append(0.0) # fill as a place holder
4857  VBuffB.append(0.0) # fill as a place holder
4858  IBuffB.append(0.0) # fill as a place holder
4859  IBuffB.append(0.0) # fill as a place holder
4860  elif ADC_Mux_Mode.get() == 5: # VB and IB
4861  VBuffB.append(ADsignal1[index][0][1])
4862  VBuffB.append(ADsignal1[index][1][0])
4863  IBuffB.append(ADsignal1[index][0][0])
4864  IBuffB.append(ADsignal1[index][1][1])
4865  if Alternate_Sweep_Mode.get() == 0:
4866  VBuffA.append(0.0) # fill as a place holder
4867  VBuffA.append(0.0) # fill as a place holder
4868  IBuffA.append(0.0) # fill as a place holder
4869  IBuffA.append(0.0) # fill as a place holder
4870  else:
4871  VBuffA.append(ADsignal1[index][0][0])
4872  IBuffA.append(ADsignal1[index][0][1])
4873  VBuffB.append(ADsignal1[index][1][0])
4874  IBuffB.append(ADsignal1[index][1][1])
4875  index = index + increment
4876 #
4877  if Alternate_Sweep_Mode.get() == 1 and Two_X_Sample.get() == 1:
4878  if len(VBuffA) < 4:
4879  index = 0
4880  while index < SHOWsamples:
4881  VBuffA.append(0.0) # fill as a place holder
4882  index = index + increment
4883  if len(VBuffB) < 4:
4884  index = 0
4885  while index < SHOWsamples:
4886  VBuffB.append(0.0) # fill as a place holder
4887  index = index + increment
4888  if len(IBuffA) < 4:
4889  index = 0
4890  while index < SHOWsamples:
4891  IBuffA.append(0.0) # fill as a place holder
4892  index = index + increment
4893  if len(IBuffB) < 4:
4894  index = 0
4895  while index < SHOWsamples:
4896  IBuffB.append(0.0) # fill as a place holder
4897  index = index + increment
4898 #
4899  if ADC_Mux_Mode.get() == 0: # VA and VB
4900  VBuffA = numpy.array(VBuffA)
4901  VBuffB = numpy.array(VBuffB)
4902  VBuffA = (VBuffA - InOffA) * InGainA
4903  VBuffB = (VBuffB - InOffB) * InGainB
4904  ADC_Mux_Mode.set(1) # switch mode
4905  Last_ADC_Mux_Mode = 0
4906  elif ADC_Mux_Mode.get() == 1: # IA and IB
4907  IBuffA = numpy.array(IBuffA) * 1000 # convert to mA
4908  IBuffB = numpy.array(IBuffB) * 1000 # convert to mA
4909  IBuffA = (IBuffA - CurOffA) * CurGainA
4910  IBuffB = (IBuffB - CurOffB) * CurGainB
4911  ADC_Mux_Mode.set(Last_ADC_Mux_Mode) # switch mode
4912  elif ADC_Mux_Mode.get() == 4: # VA and IA
4913  VBuffA = numpy.array(VBuffA)
4914  IBuffA = numpy.array(IBuffA) * 1000 # convert to mA
4915  IBuffA = (IBuffA - CurOffA) * CurGainA
4916  VBuffA = (VBuffA - InOffA) * InGainA
4917  ADC_Mux_Mode.set(1) # switch mode
4918  Last_ADC_Mux_Mode = 4
4919  elif ADC_Mux_Mode.get() == 5: # VB and IB
4920  VBuffB = numpy.array(VBuffB)
4921  VBuffB = (VBuffB - InOffB) * InGainB
4922  IBuffB = numpy.array(IBuffB) * 1000 # convert to mA
4923  IBuffB = (IBuffB - CurOffB) * CurGainB
4924  ADC_Mux_Mode.set(1) # switch mode
4925  Last_ADC_Mux_Mode = 5
4926  SetADC_Mux()
4927  #
4928  else:
4929  VBuffA = numpy.array(VBuffA)
4930  VBuffB = numpy.array(VBuffB)
4931  IBuffA = numpy.array(IBuffA) * 1000 # convert to mA
4932  IBuffB = numpy.array(IBuffB) * 1000 # convert to mA
4933  VBuffA = (VBuffA - InOffA) * InGainA
4934  VBuffB = (VBuffB - InOffB) * InGainB
4935  IBuffA = (IBuffA - CurOffA) * CurGainA
4936  IBuffB = (IBuffB - CurOffB) * CurGainB
4937  TRACESread = 2
4938  SHOWsamples = len(VBuffA)
4939 # temp ETS calculations
4940  if ETSDisp.get() > 0:
4941  baseFreq = SAMPLErate/DivX
4942  #
4943  VAets = []
4944  VBets = []
4945  IAets = []
4946  IBets = []
4947  index = 0
4948  try:
4949  FMul = float(eval(FminEntry.get()))
4950  if FMul < 1:
4951  FMul = 1
4952  FMulXEntry.delete(0,END)
4953  FMulXEntry.insert(0, int(FMul))
4954  if FMul > 75:
4955  FMul = 75
4956  FMulXEntry.delete(0,END)
4957  FMulXEntry.insert(0, int(FMul))
4958  except:
4959  FMulXEntry.delete(0,END)
4960  FMulXEntry.insert(0, int(FMul))
4961  Fmin = baseFreq * FMul
4962  FminE = float(SAMPLErate + FOff)
4963  Samples_Cycle = SAMPLErate/FminE # calculate number of samples per cycle
4964  # length of record set my Multiplcation factor
4965  tot_cycles = int((MulX*100)/Samples_Cycle)
4966  tot_cycles = tot_cycles + 0.1 # number of cycles in record length
4967  ETSrecord = int((MulX*50)/Samples_Cycle)
4968  if tot_cycles > SHOWsamples:
4969  tot_cycles = SHOWsamples-1
4970  # now sort RT data into ETS sample buffers
4971  while index < SHOWsamples:
4972  Ipart, Dpart = divmod( index*Samples_Cycle, 1)
4973  IndexValue = int(tot_cycles * Dpart)
4974  if IndexValue > SHOWsamples:
4975  IndexValue = SHOWsamples-1
4976  if IndexValue > tot_cycles:
4977  IndexValue = tot_cycles
4978  if ETSDir.get() == 0:
4979  VAets.append(VBuffA[IndexValue])
4980  VBets.append(VBuffB[IndexValue])
4981  IAets.append(IBuffA[IndexValue])
4982  IBets.append(IBuffB[IndexValue])
4983  else:
4984  VAets.append(VBuffA[int(tot_cycles-IndexValue)])
4985  VBets.append(VBuffB[int(tot_cycles-IndexValue)])
4986  IAets.append(IBuffA[int(tot_cycles-IndexValue)])
4987  IBets.append(IBuffB[int(tot_cycles-IndexValue)])
4988  index = index + 1
4989  SHiftFact = 5
4990  TimeCorrection = int(SHiftFact ) # correct for 5 uSec CHB time offset
4991  VBuffA = VAets
4992  VBuffB = VBets
4993  IBuffA = IAets
4994  IBuffB = IBets
4995  VBuffA = numpy.array(VBuffA)
4996  VBuffB = numpy.array(VBuffB)
4997  IBuffA = numpy.array(IBuffA)
4998  IBuffB = numpy.array(IBuffB)
4999  try:
5000  TimeCorrection = int(float(eval(ETSts.get())) * TimeCorrection)
5001  except:
5002  TimeCorrection = SHiftFact
5003  if ETSDir.get() == 0:
5004  VBuffB = numpy.roll(VBuffB, TimeCorrection)
5005  IBuffB = numpy.roll(IBuffB, TimeCorrection)
5006  else:
5007  VBuffB = numpy.roll(VBuffB, TimeCorrection)
5008  IBuffB = numpy.roll(IBuffB, TimeCorrection)
5009  SHOWsamples = twoscreens + hldn + hozpos
5010 # Check if Input channel RC high pass compensation checked
5011  if CHA_RC_HP.get() == 1 or CHAI_RC_HP.get() == 1:
5012  try:
5013  TC1A = float(cha_TC1Entry.get())
5014  if TC1A < 0:
5015  TC1A = 0
5016  cha_TC1Entry.delete(0,END)
5017  cha_TC1Entry.insert(0, TC1A)
5018  except:
5019  TC1A = CHA_TC1.get()
5020  try:
5021  TC2A = float(cha_TC2Entry.get())
5022  if TC2A < 0:
5023  TC2A = 0
5024  cha_TC2Entry.delete(0,END)
5025  cha_TC2Entry.insert(0, TC2A)
5026  except:
5027  TC2A = CHA_TC2.get()
5028  #
5029  try:
5030  Gain1A = float(cha_A1Entry.get())
5031  except:
5032  Gain1A = CHA_A1.get()
5033  try:
5034  Gain2A = float(cha_A2Entry.get())
5035  except:
5036  Gain2A = CHA_A2.get()
5037  #
5038  if len(VBuffA) > 4:
5039  VBuffA = Digital_RC_High_Pass( VBuffA, TC1A, Gain1A )
5040  VBuffA = Digital_RC_High_Pass( VBuffA, TC2A, Gain2A )
5041  if CHAI_RC_HP.get() == 1:
5042  IBuffA = Digital_RC_High_Pass( IBuffA, TC1A, Gain1A )
5043  #IBuffA = Digital_RC_High_Pass( IBuffA, TC2A, Gain2A )
5044  if CHB_RC_HP.get() == 1 or CHBI_RC_HP.get() == 1:
5045  try:
5046  TC1B = float(chb_TC1Entry.get())
5047  if TC1B < 0:
5048  TC1B = 0
5049  chb_TC1Entry.delete(0, END)
5050  chb_TC1Entry.insert(0, TC1B)
5051  except:
5052  TC1B = CHB_TC1.get()
5053  try:
5054  TC2B = float(chb_TC2Entry.get())
5055  if TC2B < 0:
5056  TC2B = 0
5057  chb_TC2Entry.delete(0, END)
5058  chb_TC2Entry.insert(0, TC2B)
5059  except:
5060  TC2B = CHB_TC2.get()
5061  #
5062  try:
5063  Gain1B = float(chb_A1Entry.get())
5064  except:
5065  Gain1B = CHB_A1.get()
5066  try:
5067  Gain2B = float(chb_A2Entry.get())
5068  except:
5069  Gain2B = CHB_A2.get()
5070  #
5071  if len(VBuffB) > 4:
5072  VBuffB = Digital_RC_High_Pass( VBuffB, TC1B, Gain1B )
5073  VBuffB = Digital_RC_High_Pass( VBuffB, TC2B, Gain2B )
5074  if CHBI_RC_HP.get() == 1:
5075  IBuffB = Digital_RC_High_Pass( IBuffB, TC1B, Gain1B )
5076  #IBuffB = Digital_RC_High_Pass( IBuffB, TC2B, Gain2B )
5077 # Check if need to DeSkew waveform data
5078  if DigDeSkewA.get() > 0:
5079  Shift = int(BCASkewEntry.get())
5080  if Shift != 0:
5081  VBuffA = numpy.roll(VBuffA, Shift)
5082  if DigDeSkewB.get() > 0:
5083  Shift = int(BCBSkewEntry.get())
5084  if Shift != 0:
5085  VBuffB = numpy.roll(VBuffB, Shift)
5086 # check if digital filter box checked
5087  if DigFiltA.get() == 1:
5088  if len(DFiltACoef) > 1:
5089  VBuffA = numpy.convolve(VBuffA, DFiltACoef)
5090  if DigFiltB.get() == 1:
5091  if len(DFiltBCoef) > 1:
5092  VBuffB = numpy.convolve(VBuffB, DFiltBCoef)
5093 # Find trigger sample point if necessary
5094  LShift = 0
5095  if ChopMuxMode.get() > 0 and MuxScreenStatus.get() > 0:
5096  if ChopTrig.get() == 1:
5097  FindTriggerSample(VBuffMA)
5098  if ChopTrig.get() == 2:
5099  FindTriggerSample(VBuffMB)
5100  if ChopTrig.get() == 3:
5101  FindTriggerSample(VBuffMC)
5102  if ChopTrig.get() == 4:
5103  FindTriggerSample(VBuffMD)
5104  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
5105  # Average mode 1, add difference / TRACEaverage to array
5106  if ChopMuxMode.get() == 1 and ChopTrig.get() > 0:
5107  LShift = 0 - TRIGGERsample
5108  VBuffMA = numpy.roll(VBuffMA, LShift)
5109  VBuffMB = numpy.roll(VBuffMB, LShift)
5110  VBuffMC = numpy.roll(VBuffMC, LShift)
5111  VBuffMD = numpy.roll(VBuffMD, LShift)
5112  IBuffA = numpy.roll(IBuffA, LShift)
5113  IBuffB = numpy.roll(IBuffB, LShift)
5114  TRIGGERsample = hozpos # set trigger sample to index 0 offset by horizontal position
5115  if ChopTrig.get() == 1:
5116  ReInterploateTrigger(VBuffMA)
5117  if ChopTrig.get() == 2:
5118  ReInterploateTrigger(VBuffMB)
5119  if ChopTrig.get() == 3:
5120  ReInterploateTrigger(VBuffMC)
5121  if ChopTrig.get() == 4:
5122  ReInterploateTrigger(VBuffMD)
5123  else:
5124  if TgInput.get() == 1:
5125  FindTriggerSample(VBuffA)
5126  if TgInput.get() == 2:
5127  FindTriggerSample(IBuffA)
5128  if TgInput.get() == 3:
5129  FindTriggerSample(VBuffB)
5130  if TgInput.get() == 4:
5131  FindTriggerSample(IBuffB)
5132  if TgInput.get() == 5:
5133  FindTriggerSample(VBuffA)
5134  if Is_Triggered == 0: # Trigger event not found for VBuffA so Try VBuffB
5135  FindTriggerSample(VBuffB)
5136  if TgInput.get() == 6:
5137  FindTriggerSample(VBuffA)
5138  TRIGGERsampleAltA = TRIGGERsample
5139  FindTriggerSample(VBuffB)
5140  TRIGGERsampleAltB = TRIGGERsample
5141  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
5142  # Average mode 1, add difference / TRACEaverage to array
5143  if TgInput.get() > 0: # if triggering left shift all arrays such that trigger point is at index 0
5144  LShift = 0 - TRIGGERsample
5145  if TgInput.get() == 6:
5146  LShift = 0 - TRIGGERsampleAltA
5147  VBuffA = numpy.roll(VBuffA, LShift)
5148  IBuffA = numpy.roll(IBuffA, LShift)
5149  LShift = 0 - TRIGGERsampleAltB
5150  VBuffB = numpy.roll(VBuffB, LShift)
5151  IBuffB = numpy.roll(IBuffB, LShift)
5152  else:
5153  VBuffA = numpy.roll(VBuffA, LShift)
5154  VBuffB = numpy.roll(VBuffB, LShift)
5155  IBuffA = numpy.roll(IBuffA, LShift)
5156  IBuffB = numpy.roll(IBuffB, LShift)
5157  TRIGGERsample = hozpos # set trigger sample to index 0 offset by horizontal position
5158  if UnAvgSav.get() == 1: # copy un averaged trace to buffer
5159  VUnAvgA = VBuffA
5160  VUnAvgB = VBuffB
5161  IUnAvgA = IBuffA
5162  IUnAvgB = IBuffB
5163  try:
5164  if DualMuxMode.get() == 0: # and MuxScreenStatus.get() == 0: # average A voltage data only if not in dual split I/O Mux Mode
5165  VBuffA = VmemoryA + (VBuffA - VmemoryA) / TRACEaverage.get()
5166  IBuffA = ImemoryA + (IBuffA - ImemoryA) / TRACEaverage.get()
5167  if MuxScreenStatus.get() == 0: # average B voltage data only if not in Mux Mode
5168  VBuffB = VmemoryB + (VBuffB - VmemoryB) / TRACEaverage.get()
5169  IBuffB = ImemoryB + (IBuffB - ImemoryB) / TRACEaverage.get()
5170  except:
5171  # buffer size mismatch so reset memory buffers
5172  VmemoryA = VBuffA
5173  if MuxScreenStatus.get() == 0: # average B voltage data only if not in Mux Mode
5174  VmemoryB = VBuffB
5175  ImemoryA = IBuffA
5176  ImemoryB = IBuffB
5177  if TgInput.get() == 1 or TgInput.get() == 5 or TgInput.get() == 6:
5178  ReInterploateTrigger(VBuffA)
5179  if TgInput.get() == 2:
5180  ReInterploateTrigger(IBuffA)
5181  if TgInput.get() == 3 or TgInput.get() == 5 or TgInput.get() == 6:
5182  ReInterploateTrigger(VBuffB)
5183  if TgInput.get() == 4:
5184  ReInterploateTrigger(IBuffB)
5185 # DC value = average of the data record
5186  if CHA_RC_HP.get() == 1 or CHB_RC_HP.get() == 1:
5187  Endsample = hldn+onescreen # average over only one screen's worth of samples
5188  else:
5189  Endsample = SHOWsamples - 10 # average over all samples
5190  if MeasGateStatus.get() == 1:
5191  if (MeasGateRight-MeasGateLeft) > 0:
5192  hldn = int(MeasGateLeft * SAMPLErate/1000) + TRIGGERsample
5193  Endsample = int(MeasGateRight * SAMPLErate/1000) + TRIGGERsample
5194  if Endsample <= hldn:
5195  Endsample = hldn + 2
5196 # Calculate scalar values
5197  Cal_trace_scalars(hldn, Endsample)
5198 # Transfer to mux buffers as necessary
5199  if TgInput.get() > 0 and TRACEmodeTime.get() != 1: # and MuxChan > -1
5200  # if triggering left shift all arrays such that trigger point is at index 0
5201  LShift = 0 - TRIGGERsample
5202  VBuffA = numpy.roll(VBuffA, LShift)
5203  VBuffB = numpy.roll(VBuffB, LShift)
5204  IBuffA = numpy.roll(IBuffA, LShift)
5205  IBuffB = numpy.roll(IBuffB, LShift)
5206  TRIGGERsample = hozpos # set trigger sample to index 0 offset by horizontal position
5207  if ChopMuxMode.get() == 1 and ChopTrig.get() > 0 and TRACEmodeTime.get() != 1:
5208  LShift = 0 - TRIGGERsample
5209  VBuffMA = numpy.roll(VBuffMA, LShift)
5210  VBuffMB = numpy.roll(VBuffMB, LShift)
5211  VBuffMC = numpy.roll(VBuffMC, LShift)
5212  VBuffMD = numpy.roll(VBuffMD, LShift)
5213  IBuffA = numpy.roll(IBuffA, LShift)
5214  IBuffB = numpy.roll(IBuffB, LShift)
5215  TRIGGERsample = hozpos # set trigger sample to index 0 offset by horizontal position
5216  if ChopMuxMode.get() == 1 and TRACEmodeTime.get() == 1: # also if in chop mode cal avaerage
5217  # Average mode 1, add difference / TRACEaverage to array
5218  try:
5219  VBuffMA = VmemoryMuxA + (VBuffMA - VmemoryMuxA) / TRACEaverage.get()
5220  except: # buffer size mismatch so reset memory buffers
5221  VmemoryMuxA = VBuffMA
5222  try:
5223  VBuffMB = VmemoryMuxB + (VBuffMB - VmemoryMuxB) / TRACEaverage.get()
5224  except: # buffer size mismatch so reset memory buffers
5225  VmemoryMuxB = VBuffMB
5226  try:
5227  VBuffMC = VmemoryMuxC + (VBuffMC - VmemoryMuxC) / TRACEaverage.get()
5228  except: # buffer size mismatch so reset memory buffers
5229  VmemoryMuxC = VBuffMC
5230  try:
5231  VBuffMD = VmemoryMuxD + (VBuffMD - VmemoryMuxD) / TRACEaverage.get()
5232  except: # buffer size mismatch so reset memory buffers
5233  VmemoryMuxD = VBuffMD
5234  if MuxChan > -1 and ChopMuxMode.get() == 0: # do this when not in chop mux mode
5235  if Show_CBA.get() == 1 and MuxChan == 0: # Dval0[0] == 0 and Dval1[0] == 0 and ChopMuxMode.get() == 0:
5236  DCVMuxA = DCV2
5237  MinVMuxA = MinV2
5238  MaxVMuxA = MaxV2
5239  MidVMuxA = (MaxV2+MinV2)/2.0
5240  PPVMuxA = MaxV2-MinV2
5241  SVMuxA = SV2
5242  VBuffMA = VBuffB
5243  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
5244  # Average mode 1, add difference / TRACEaverage to array
5245  try:
5246  VBuffMA = VmemoryMuxA + (VBuffMA - VmemoryMuxA) / TRACEaverage.get()
5247  except:
5248  # buffer size mismatch so reset memory buffers
5249  VmemoryMuxA = VBuffMA
5250  if Show_CBB.get() == 1 and MuxChan == 1: # Dval0[0] == 1 and Dval1[0] == 0 and ChopMuxMode.get() == 0:
5251  DCVMuxB = DCV2
5252  MinVMuxB = MinV2
5253  MaxVMuxB = MaxV2
5254  MidVMuxB = (MaxV2+MinV2)/2.0
5255  PPVMuxB = MaxV2-MinV2
5256  SVMuxB = SV2
5257  VBuffMB = VBuffB
5258  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
5259  # Average mode 1, add difference / TRACEaverage to array
5260  try:
5261  VBuffMB = VmemoryMuxB + (VBuffMB - VmemoryMuxB) / TRACEaverage.get()
5262  except:
5263  # buffer size mismatch so reset memory buffers
5264  VmemoryMuxB = VBuffMB
5265  if Show_CBC.get() == 1 and MuxChan == 2: #and Dval0[0] == 0 and Dval1[0] == 1
5266  if DualMuxMode.get() == 1 :
5267  DCVMuxC = DCV1
5268  MinVMuxC = MinV1
5269  MaxVMuxC = MaxV1
5270  MidVMuxC = (MaxV1+MinV1)/2.0
5271  PPVMuxC = MaxV1-MinV1
5272  SVMuxC = SV1
5273  VBuffMC = VBuffA
5274  else:
5275  DCVMuxC = DCV2
5276  MinVMuxC = MinV2
5277  MaxVMuxC = MaxV2
5278  MidVMuxC = (MaxV2+MinV2)/2.0
5279  PPVMuxC = MaxV2-MinV2
5280  SVMuxC = SV2
5281  VBuffMC = VBuffB
5282  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
5283  # Average mode 1, add difference / TRACEaverage to array
5284  try:
5285  VBuffMC = VmemoryMuxC + (VBuffMC - VmemoryMuxC) / TRACEaverage.get()
5286  except:
5287  # buffer size mismatch so reset memory buffers
5288  VmemoryMuxC = VBuffMC
5289  if Show_CBD.get() == 1 and MuxChan == 3: #and Dval0[0] == 1 and Dval1[0] == 1
5290  if DualMuxMode.get() == 1 :
5291  DCVMuxD = DCV1
5292  MinVMuxD = MinV1
5293  MaxVMuxD = MaxV1
5294  MidVMuxD = (MaxV1+MinV1)/2.0
5295  PPVMuxD = MaxV1-MinV1
5296  SVMuxD = SV1
5297  VBuffMD = VBuffA
5298  else:
5299  DCVMuxD = DCV2
5300  MinVMuxD = MinV2
5301  MaxVMuxD = MaxV2
5302  MidVMuxD = (MaxV2+MinV2)/2.0
5303  PPVMuxD = MaxV2-MinV2
5304  SVMuxD = SV2
5305  VBuffMD = VBuffB
5306  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
5307  # Average mode 1, add difference / TRACEaverage to array
5308  try:
5309  VBuffMD = VmemoryMuxD + (VBuffMD - VmemoryMuxD) / TRACEaverage.get()
5310  except:
5311  # buffer size mismatch so reset memory buffers
5312  VmemoryMuxD = VBuffMD
5313  # update screens
5314  if TimeDisp.get() > 0:
5315  # Check if in non functional state of 2X samplerate and 3 or more traces and not enabled AWGSync
5316  NumTraces = ShowC1_V.get() + ShowC1_I.get() + ShowC2_V.get() + ShowC2_I.get()
5317  if NumTraces > 2 and AWGSync.get() == 0 and Two_X_Sample.get() == 1:
5318  showwarning("WARNING","You need to Select only 2 Traces or Enable AWG Sync Mode!")
5319  BStop()
5320  # return
5321  UpdateTimeAll() # Update Data, trace and time screen
5322  if XYDisp.get() > 0 and XYScreenStatus.get() > 0:
5323  UpdateXYAll() # Update Data, trace and XY screen
5324  if SingleShot.get() > 0 and Is_Triggered == 1: # Singel Shot trigger is on
5325  BStop() #
5326  SingleShot.set(0)
5327  if ManualTrigger.get() == 1: # Manual trigger is on
5328  BStop() #
5329  if MeasureStatus.get() > 0:
5331 #
5332 # Calculate waveform scalar values
5333 def Cal_trace_scalars(SampleStart, SampleEnd):
5334  global VBuffA, VBuffB, IBuffA, IBuffB
5335  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
5336  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
5337  global SV1, SI1, SV2, SI2, SVA_B
5338 
5339  DCV1 = numpy.mean(VBuffA[SampleStart:SampleEnd])
5340  DCV2 = numpy.mean(VBuffB[SampleStart:SampleEnd])
5341  DCI1 = numpy.mean(IBuffA[SampleStart:SampleEnd])
5342  DCI2 = numpy.mean(IBuffB[SampleStart:SampleEnd])
5343 # find min and max values
5344  MinV1 = numpy.amin(VBuffA[SampleStart:SampleEnd])
5345  MaxV1 = numpy.amax(VBuffA[SampleStart:SampleEnd])
5346  MinV2 = numpy.amin(VBuffB[SampleStart:SampleEnd])
5347  MaxV2 = numpy.amax(VBuffB[SampleStart:SampleEnd])
5348  MinI1 = numpy.amin(IBuffA[SampleStart:SampleEnd])
5349  MaxI1 = numpy.amax(IBuffA[SampleStart:SampleEnd])
5350  MinI2 = numpy.amin(IBuffB[SampleStart:SampleEnd])
5351  MaxI2 = numpy.amax(IBuffB[SampleStart:SampleEnd])
5352 # RMS value = square root of average of the data record squared
5353  SV1 = numpy.sqrt(numpy.mean(numpy.square(VBuffA[SampleStart:SampleEnd])))
5354  SI1 = numpy.sqrt(numpy.mean(numpy.square(IBuffA[SampleStart:SampleEnd])))
5355  SV2 = numpy.sqrt(numpy.mean(numpy.square(VBuffB[SampleStart:SampleEnd])))
5356  SI2 = numpy.sqrt(numpy.mean(numpy.square(IBuffB[SampleStart:SampleEnd])))
5357  SVA_B = numpy.sqrt(numpy.mean(numpy.square(VBuffA[SampleStart:SampleEnd]-VBuffB[SampleStart:SampleEnd])))
5358 #
5359 # Function to calculate relative phase angle between two sine waves of the same frequency
5360 # Removes any DC content
5361 def Sine_Phase():
5362  global DCV1, DCV2, VBuffA, VBuffB
5363 
5364  sum1 = 0.0
5365  sum2 = 0.0
5366  sum12 = 0.0
5367  i = 0
5368  n = len(VBuffA)
5369  while i < n:
5370  sum1 += (VBuffA[i]-DCV1)*(VBuffA[i]-DCV1)
5371  sum2 += (VBuffB[i]-DCV2)*(VBuffB[i]-DCV2)
5372  sum12 += (VBuffA[i]-DCV1)*(VBuffB[i]-DCV2)
5373  i += 1
5374  return math.acos(sum12/math.sqrt(sum1*sum2))*180.0/numpy.pi
5375 #
5376 # High Pass y[n] = alpha * (y[n-1] + x[n] - x[n-1])
5377 # Low Pass y[n] = y[n-1] + (alpha * ((x[n] - x[n-1]))
5378 # All Pass y[n] = alpha * y[n-1] - alpha * (x[n] + x[n-1])
5379 # All Pass y[n] = alpha * (y[n-1] - x[n] - x[n-1])
5380 
5381 
5383 def Digital_RC_High_Pass( InBuff, TC1, Gain ):
5384  global SAMPLErate, Two_X_Sample
5385 
5386  OutBuff = []
5387  n = len(InBuff)
5388  if Two_X_Sample.get() == 0:
5389  Delta = 1.0/SAMPLErate
5390  else: # adjust for sligh difference in 2X sample mode?
5391  Delta = 0.88/SAMPLErate
5392  TC = TC1 * 1.0E-6
5393  Alpha = TC / (TC + Delta)
5394  OutBuff.append(0.0) # initialize first output sample
5395  i = 1
5396  while i < n:
5397  OutBuff.append( Alpha * (OutBuff[i-1] + InBuff[i] - InBuff[i-1]) )
5398  i += 1
5399  OutBuff = numpy.array(OutBuff)
5400  OutBuff = InBuff + (OutBuff * Gain)
5401  return OutBuff
5402 
5404 def Digital_RC_Low_Pass( InBuff, TC1, Gain ): # TC1 is in micro seconds
5405  global SAMPLErate
5406 
5407  OutBuff = []
5408  n = len(InBuff)
5409  Delta = 1.0/SAMPLErate
5410  TC = TC1 * 1.0E-6
5411  Alpha = Delta / (TC + Delta)
5412  i = 1
5413  OutBuff.append(Alpha*InBuff[0])
5414  while i < n:
5415  OutBuff.append( OutBuff[i-1] + (Alpha * (InBuff[i] - InBuff[i-1])) )
5416  i += 1
5417  OutBuff = numpy.array(OutBuff)
5418  OutBuff = (OutBuff * Gain)
5419  return OutBuff
5420 
5424 def shift_buffer(arr, num, fill_value=numpy.nan):
5425  result = numpy.empty_like(arr)
5426  if num > 0:
5427  result[:num] = fill_value
5428  result[num:] = arr[:-num]
5429  elif num < 0:
5430  result[num:] = fill_value
5431  result[:num] = arr[-num:]
5432  else:
5433  result[:] = arr
5434  return result
5435 
5436 
5438 def Analog_Freq_In():
5439  global ADsignal1, FFTBuffA, FFTBuffB, SMPfft
5440  global AWGSync, AWGAMode, AWGBMode, AWGAShape, AWGAIOMode, AWGBIOMode
5441  global AWGAFreqvalue, AWGBFreqvalue, FStepSync, FSweepSync
5442  global NSteps, LoopNum, FSweepMode, FStep, FBins
5443  global StartFreqEntry, StopFreqEntry, HoldOffentry
5444  global session, CHA, CHB, devx, MaxSamples, discontloop
5445  global RUNstatus, SingleShotSA, FSweepCont, Two_X_Sample, ADC_Mux_Mode
5446  global AWGSAMPLErate, IAScreenStatus, SpectrumScreenStatus, BodeScreenStatus
5447  global NiCScreenStatus, NiCDisp, NqPScreenStatus, NqPDisp
5448  global OverRangeFlagA, OverRangeFlagB, BodeDisp, FreqDisp, IADisp
5449  global DCA, DCB, InOffA, InGainA, InOffB, InGainB
5450  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
5451  global DigFiltA, DFiltACoef, DigFiltB, DFiltBCoef
5452  global BDSweepFile, FileSweepFreq, FileSweepAmpl
5453  global PIO_0, PIO_1, PIO_2, PIO_3
5454  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
5455  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
5456  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
5457  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
5458  global Reset_Freq, AWGAFreqEntry, AWGBFreqEntry, MinigenFout, IASource, IA_Ext_Conf
5459 
5460  HalfSAMPLErate = SAMPLErate/2
5461  # Do input divider Calibration CH1VGain, CH2VGain, CH1VOffset, CH2VOffset
5462  try:
5463  InOffA = float(eval(CHAVOffsetEntry.get()))
5464  except:
5465  CHAVOffsetEntry.delete(0,END)
5466  CHAVOffsetEntry.insert(0, InOffA)
5467  try:
5468  InGainA = float(eval(CHAVGainEntry.get()))
5469  except:
5470  CHAVGainEntry.delete(0,END)
5471  CHAVGainEntry.insert(0, InGainA)
5472  try:
5473  InOffB = float(eval(CHBVOffsetEntry.get()))
5474  except:
5475  CHBVOffsetEntry.delete(0,END)
5476  CHBVOffsetEntry.insert(0, InOffB)
5477  try:
5478  InGainB = float(eval(CHBVGainEntry.get()))
5479  except:
5480  CHBVGainEntry.delete(0,END)
5481  CHBVGainEntry.insert(0, InGainB)
5482  try:
5483  HoldOff = float(eval(HoldOffentry.get()))
5484  if HoldOff < 0:
5485  HoldOff = 0
5486  HoldOffentry.delete(0,END)
5487  HoldOffentry.insert(0, HoldOff)
5488  except:
5489  HoldOffentry.delete(0,END)
5490  HoldOffentry.insert(0, HoldOff)
5491  #
5492  INITIALIZEstart()
5493  # Starting acquisition This is a HACK to get around non-continous AWG mode!
5494  # restart AWGs if indicated
5495  if BodeDisp.get() == 0: # make new noise waveforms each sweep
5496  if AWGAShape.get() == 7 and AWGAMode.get() == 0:
5497  AWGAMakeUUNoise()
5498  elif AWGAShape.get() == 8 and AWGAMode.get() == 0:
5499  AWGAMakeUGNoise()
5500  elif AWGBShape.get() == 7 and AWGBMode.get() == 0:
5501  AWGBMakeUUNoise()
5502  elif AWGBShape.get() == 8 and AWGBMode.get() == 0:
5503  AWGBMakeUGNoise()
5504  if FSweepMode.get() > 0 and BodeDisp.get() > 0: # Run Sweep Gen only if sleceted and Bode display is active
5505  if BDSweepFile.get() == 0:
5506  if LoopNum.get() <= len(FStep):
5507  FregPoint = FBins[int(FStep[LoopNum.get()-1])] # look up next frequency from list of bins
5508  else:
5509  FregPoint = FBins[FStep[0]]
5510  else:
5511  if LoopNum.get() <= len(FileSweepFreq): #
5512  FreqIndex = int((FileSweepFreq[LoopNum.get()-1]*16384)/HalfSAMPLErate)
5513  FregPoint = FBins[FreqIndex] # look up next frequency from list of bins
5514  VRMSAmpl = 10**(FileSweepAmpl[LoopNum.get()-1]/20) # convert to V RMS 0 dBV = 1V RMS
5515  else:
5516  FregPoint = FBins[FileSweepFreq[0]]
5517  VRMSAmpl = 10**(FileSweepAmpl[0]/20) # convert to V RMS 0 dBV = 1V RMS
5518  VMax = 2.5 + (1.414*VRMSAmpl) # calculate positive peak assuming sine wave
5519  VMin = 2.5 - (1.414*VRMSAmpl) # calculate negative peak assuming sine wave
5520  if FSweepMode.get() == 1: # set new CH-A amplitude
5521  AWGAAmplEntry.delete(0,END)
5522  AWGAAmplEntry.insert(4, VMin)
5523  AWGAOffsetEntry.delete(0,END)
5524  AWGAOffsetEntry.insert(4, VMax)
5525  if FSweepMode.get() == 2: # set new CH-B amplitude
5526  AWGBAmplEntry.delete(0,END)
5527  AWGBAmplEntry.insert(4, VMin)
5528  AWGBOffsetEntry.delete(0,END)
5529  AWGBOffsetEntry.insert(4, VMax)
5530  if FSweepMode.get() == 1: # set new CH-A frequency
5531  AWGAFreqEntry.delete(0,END)
5532  AWGAFreqEntry.insert(4, FregPoint)
5534  if FSweepMode.get() == 2: # set new CH-B frequency
5535  AWGBFreqEntry.delete(0,END)
5536  AWGBFreqEntry.insert(4, FregPoint)
5538  if FSweepMode.get() == 3: # set new MiniGen frequency
5539  MinigenFout.delete(0,END)
5540  MinigenFout.insert(4, FregPoint)
5541  BSendMG()
5542  if AWGSync.get() > 0:
5543  if IAScreenStatus.get() > 0 and IASource.get() == 0:
5544  if Two_X_Sample.get() == 1:
5545  AWGBIOMode.set(1)
5546  AWGBMode.set(0)
5547  else:
5548  AWGBMode.set(2)
5549  # BAWGEnab()
5550 #
5551  hldn = int(HoldOff * 100 )
5552  if hldn > MaxSamples-SMPfft:
5553  hldn = MaxSamples-SMPfft
5554  HoldOffentry.delete(0,END)
5555  HoldOffentry.insert(0, hldn/100)
5556  if hldn < 128:
5557  hldn = 128
5558  SHOWsamples = SMPfft + hldn # get holf off extra samples
5559  if BodeDisp.get() > 0: # check if doing Bode Plot
5560  if FStepSync.get() == 1: # output low - high - low pulse on PIO-0
5561  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100)
5562  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100)
5563  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100)
5564  if FStepSync.get() == 2: # output high - low - high pulse on PIO-0
5565  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100)
5566  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100)
5567  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100)
5568  if LoopNum.get() == 1 and FSweepSync.get() == 1: # output low - high - low pulse on PIO-1
5569  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100)
5570  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100)
5571  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100)
5572  if LoopNum.get() == 1 and FSweepSync.get() == 2: # output high - low - high pulse on PIO-1
5573  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100)
5574  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100)
5575  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100)
5576  if AWGScreenStatus.get() == 1: # don't try to start AWG is AWG screen is closed
5577  if IAScreenStatus.get() > 0 and IASource.get() == 0:
5578  if Two_X_Sample.get() == 1:
5579  AWGBIOMode.set(1)
5580  AWGBMode.set(0)
5581  else:
5582  AWGBMode.set(2)
5583  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
5584  if discontloop > 0:
5585  session.flush()
5586  else:
5587  discontloop = 1
5588  BAWGEnab()
5589  try:
5590  ADsignal1 = devx.get_samples(SHOWsamples) # get samples for both channel A and B
5591  except:
5592  donothing()
5593  # waite to finish then return to open termination
5594  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
5595  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
5596  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
5597  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
5598  else: # running in continuous mode
5599  ADsignal1 = devx.read(SHOWsamples, -1, True) # get samples for both channel A and B
5600  #
5601  else:
5602  if session.continuous:
5603  ADsignal1 = devx.read(SHOWsamples, -1, True)
5604  # ADsignal1 = devx.get_samples(SHOWsamples) # get samples for both channel A and B
5605  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
5606  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
5607  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
5608  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
5609  FFTBuffA = [] # Clear the FFTBuff array for trace A
5610  FFTBuffB = [] # Clear the FFTBuff array for trace B
5611  OverRangeFlagA = OverRangeFlagB = 0 # Clear over range flags
5612  index = hldn # skip first hldn samples
5613  if SHOWsamples != len(ADsignal1):
5614  SHOWsamples = len(ADsignal1)
5615  while index < SHOWsamples:
5616  if Two_X_Sample.get() == 1:
5617  if ADC_Mux_Mode.get() == 0: # VA and VB
5618  FFTBuffA.append(ADsignal1[index][0][0])
5619  FFTBuffA.append(ADsignal1[index][1][1])
5620  FFTBuffB.append(ADsignal1[index][0][1])
5621  FFTBuffB.append(ADsignal1[index][1][0])
5622  else:
5623  VAdata = ADsignal1[index][0][0]
5624  FFTBuffA.append(VAdata)
5625  VBdata = ADsignal1[index][1][0]
5626  FFTBuffB.append(VBdata)
5627  if VAdata > 5.0 or VAdata < 0.0:
5628  OverRangeFlagA = 1
5629 
5630  if VBdata > 5.0 or VBdata < 0.0:
5631  OverRangeFlagB = 1
5632  index = index + 1
5633 
5634  FFTBuffA = numpy.array(FFTBuffA)
5635  FFTBuffB = numpy.array(FFTBuffB)
5636  FFTBuffA = (FFTBuffA - InOffA) * InGainA
5637  FFTBuffB = (FFTBuffB - InOffB) * InGainB
5638  DCA = numpy.average(FFTBuffA)
5639  DCB = numpy.average(FFTBuffB)
5640  if CutDC.get() == 1:
5641  FFTBuffA = FFTBuffA - DCA
5642  FFTBuffB = FFTBuffB - DCB
5643 # Check if Input channel RC high pass compensation checked cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
5644  if CHA_RC_HP.get() == 1:
5645  try:
5646  TC1A = float(cha_TC1Entry.get())
5647  if TC1A < 0:
5648  TC1A = 0
5649  cha_TC1Entry.delete(0,END)
5650  cha_TC1Entry.insert(0, TC1A)
5651  except:
5652  TC1A = CHA_TC1.get()
5653  try:
5654  TC2A = float(cha_TC2Entry.get())
5655  if TC2A < 0:
5656  TC2A = 0
5657  cha_TC2Entry.delete(0,END)
5658  cha_TC2Entry.insert(0, TC2A)
5659  except:
5660  TC2A = CHA_TC2.get()
5661  #
5662  try:
5663  Gain1A = float(cha_A1Entry.get())
5664  except:
5665  Gain1A = CHA_A1.get()
5666  try:
5667  Gain2A = float(cha_A2Entry.get())
5668  except:
5669  Gain2A = CHA_A2.get()
5670  #
5671  FFTBuffA = Digital_RC_High_Pass( FFTBuffA, TC1A, Gain1A )
5672  FFTBuffA = Digital_RC_High_Pass( FFTBuffA, TC2A, Gain2A )
5673  if CHB_RC_HP.get() == 1:
5674  try:
5675  TC1B = float(chb_TC1Entry.get())
5676  if TC1B < 0:
5677  TC1B = 0
5678  chb_TC1Entry.delete(0, END)
5679  chb_TC1Entry.insert(0, TC1B)
5680  except:
5681  TC1B = CHB_TC1.get()
5682  try:
5683  TC2B = float(chb_TC2Entry.get())
5684  if TC2B < 0:
5685  TC2B = 0
5686  chb_TC2Entry.delete(0, END)
5687  chb_TC2Entry.insert(0, TC2B)
5688  except:
5689  TC2B = CHB_TC2.get()
5690  #
5691  try:
5692  Gain1B = float(chb_A1Entry.get())
5693  except:
5694  Gain1B = CHB_A1.get()
5695  try:
5696  Gain2B = float(chb_A2Entry.get())
5697  except:
5698  Gain2B = CHB_A2.get()
5699  #
5700  FFTBuffB = Digital_RC_High_Pass( FFTBuffB, TC1B, Gain1B )
5701  FFTBuffB = Digital_RC_High_Pass( FFTBuffB, TC2B, Gain2B )
5702 # check if digital filter box checked
5703  if DigFiltA.get() == 1:
5704  FFTBuffA = numpy.convolve(FFTBuffA, DFiltACoef)
5705  if DigFiltB.get() == 1:
5706  FFTBuffB = numpy.convolve(FFTBuffB, DFiltBCoef)
5707  DoFFT()
5708  if SpectrumScreenStatus.get() > 0 and FreqDisp.get() > 0:
5709  UpdateFreqAll() # Update spectrum Data, trace and screen
5710  if IAScreenStatus.get() > 0 and IADisp.get() > 0:
5711  UpdateIAAll()
5712  if BodeScreenStatus.get() > 0 and BodeDisp.get() > 0:
5713  UpdateBodeAll()
5714  if NqPScreenStatus.get() > 0 and NqPDisp.get() > 0:
5715  UpdateNqPAll()
5716  if NiCScreenStatus.get() > 0 and NiCDisp.get() > 0:
5717  UpdateNiCAll()
5718  if SingleShotSA.get() == 1: # Single shot sweep is on
5719  RUNstatus.set(0)
5720 #
5721  if FSweepMode.get() > 0 and BodeDisp.get() > 0: # Increment loop counter only if sleceted and Bode display is active
5722  LoopNum.set(LoopNum.get() + 1)
5723  if LoopNum.get() > NSteps.get():
5724  if FSweepMode.get() == 1:
5725  AWGAFreqEntry.delete(0,"end")
5726  AWGAFreqEntry.insert(0, Reset_Freq)
5727  if FSweepMode.get() == 2:
5728  AWGBFreqEntry.delete(0,"end")
5729  AWGBFreqEntry.insert(0, Reset_Freq)
5730 #
5731  LoopNum.set(1)
5732  if FSweepCont.get() == 0:
5733  RUNstatus.set(0)
5734 #
5735 
5736 def MakeHistogram():
5737  global VBuffA, VBuffB, IBuffA, IBuffB, HBuffA, HBuffB
5738  global CH1pdvRange, CHAOffset, CH2pdvRange, CHBOffset
5739  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, Xsignal
5740  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
5741  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
5742  global VABase, VATop, VBBase, VBTop
5743 
5744  if ShowC1_V.get() == 1 or Xsignal.get() == 6:
5745  CHAGridMax = (5 * CH1pdvRange ) + CHAOffset # Calculate CHA Grid Min and Max
5746  CHAGridMin = (-5 * CH1pdvRange ) + CHAOffset
5747  VAMid = (MinV1 + MaxV1)/2 # Find CHA mid value
5748  HBuffA = numpy.histogram(VBuffA, bins=5000, range=[CHAGridMin, CHAGridMax] )
5749  LowerPeak = 0
5750  UpperPeak = 0
5751  b = 0
5752  while (b < 4999):
5753  if HBuffA[0][b] > HBuffA[0][LowerPeak] and HBuffA[1][b] < VAMid:
5754  LowerPeak = b
5755  VABase = HBuffA[1][b]
5756  if HBuffA[0][b] > HBuffA[0][UpperPeak] and HBuffA[1][b] > VAMid:
5757  UpperPeak = b
5758  VATop = HBuffA[1][b]
5759  b = b + 1
5760  if ShowC2_V.get() == 1 or Xsignal.get() == 7:
5761  CHBGridMax = (5 * CH2pdvRange ) + CHBOffset # Calculate CHB Grid Min and Max
5762  CHBGridMin = (-5 * CH2pdvRange ) + CHBOffset
5763  VBMid = (MinV2 + MaxV2)/2 # Find CHB mid value
5764  HBuffB = numpy.histogram(VBuffB, bins=5000, range=[CHBGridMin, CHBGridMax] )
5765  LowerPeak = 0
5766  UpperPeak = 0
5767  b = 0
5768  while (b < 4999):
5769  if HBuffB[0][b] > HBuffB[0][LowerPeak] and HBuffB[1][b] < VBMid:
5770  LowerPeak = b
5771  VBBase = HBuffB[1][b]
5772  if HBuffB[0][b] > HBuffB[0][UpperPeak] and HBuffB[1][b] > VBMid:
5773  UpperPeak = b
5774  VBTop = HBuffB[1][b]
5775  b = b + 1
5776 
5777 def BHistAsPercent():
5778  global HistAsPercent
5779 
5780  if askyesno("Plot as Percent", "Plot Histogram as Percent?", parent=xywindow):
5781  HistAsPercent = 1
5782  else:
5783  HistAsPercent = 0
5784 
5785 def FindRisingEdge(Trace1, Trace2):
5786  global MinV1, MaxV1, MinV2, MaxV2, HoldOff, TRIGGERsample, TgInput, LShift
5787  global ETSrecord, DISsamples
5788  global SHOWsamples, SAMPLErate, CHAperiod, CHAfreq, CHBperiod, CHBfreq
5789  global CHAHW, CHALW, CHADCy, CHBHW, CHBLW, CHBDCy, ShowC1_V, ShowC2_V
5790  global CHABphase, CHBADelayR1, CHBADelayR2, CHBADelayF
5791 
5792  anr1 = bnr1 = 0
5793  anf1 = bnf1 = 1
5794  anr2 = bnr2 = 2
5795  hldn = int(HoldOff * SAMPLErate/1000)
5796  # print(DISsamples, len(Trace1))
5797  if TgInput.get() > 0: # if triggering right shift arrays to undo trigger left shift
5798  Trace1 = numpy.roll(Trace1, -LShift)
5799  Trace2 = numpy.roll(Trace2, -LShift)
5800  else:
5801  Trace1 = numpy.roll(Trace1, -hldn)
5802  Trace2 = numpy.roll(Trace2, -hldn)
5803  try:
5804  MidV1 = (numpy.amax(Trace1)+numpy.amin(Trace1))/2.0
5805  MidV2 = (numpy.amax(Trace2)+numpy.amin(Trace2))/2.0
5806  except:
5807  MidV1 = (MinV1+MaxV1)/2
5808  MidV2 = (MinV2+MaxV2)/2
5809 # search Trace 1
5810 
5817  Arising = [i for (i, val) in enumerate(Trace1) if val >= MidV1 and Trace1[i-1] < MidV1]
5818  Afalling = [i for (i, val) in enumerate(Trace1) if val <= MidV1 and Trace1[i-1] > MidV1]
5819  AIrising = [i - (Trace1[i] - MidV1)/(Trace1[i] - Trace1[i-1]) for i in Arising]
5820  AIfalling = [i - (MidV1 - Trace1[i])/(Trace1[i-1] - Trace1[i]) for i in Afalling]
5821 
5822  CHAfreq = SAMPLErate / numpy.mean(numpy.diff(AIrising))
5823  CHAperiod = (numpy.mean(numpy.diff(AIrising)) * 1000.0) / SAMPLErate # time in mSec
5824 # Catch zero length array?
5825  try:
5826  Dummy_read = Arising[0]
5827  except:
5828  return
5829  if len(Arising) > 0 or len(Afalling) > 0:
5830  if Arising[0] > 0:
5831  try:
5832  anr1 = AIrising[0]
5833  except:
5834  anr1 = 0
5835  try:
5836  anr2 = AIrising[1]
5837  except:
5838  anr2 = SHOWsamples
5839  try:
5840  if AIfalling[0] < AIrising[0]:
5841  anf1 = AIfalling[1]
5842  else:
5843  anf1 = AIfalling[0]
5844  except:
5845  anf1 = 1
5846  else:
5847  try:
5848  anr1 = AIrising[1]
5849  except:
5850  anr1 = 0
5851  try:
5852  anr2 = AIrising[2]
5853  except:
5854  anr2 = SHOWsamples
5855  try:
5856  if AIfalling[1] < AIrising[1]:
5857  anf1 = AIfalling[2]
5858  else:
5859  anf1 = AIfalling[1]
5860  except:
5861  anf1 = 1
5862 # search Trace 2
5863 
5870  Brising = [i for (i, val) in enumerate(Trace2) if val >= MidV2 and Trace2[i-1] < MidV2]
5871  Bfalling = [i for (i, val) in enumerate(Trace2) if val <= MidV2 and Trace2[i-1] > MidV2]
5872  BIrising = [i - (Trace2[i] - MidV2)/(Trace2[i] - Trace2[i-1]) for i in Brising]
5873  BIfalling = [i - (MidV2 - Trace2[i])/(Trace2[i-1] - Trace2[i]) for i in Bfalling]
5874 
5875  CHBfreq = SAMPLErate / numpy.mean(numpy.diff(BIrising))
5876  CHBperiod = (numpy.mean(numpy.diff(BIrising)) * 1000.0) / SAMPLErate # time in mSec
5877 # Catch zero length array?
5878  try:
5879  Dummy_read = Brising[0]
5880  except:
5881  return
5882  if len(Brising) > 0 or len(Bfalling) > 0:
5883  if Brising[0] > 0:
5884  try:
5885  bnr1 = BIrising[0]
5886  except:
5887  bnr1 = 0
5888  try:
5889  bnr2 = BIrising[1]
5890  except:
5891  bnr2 = SHOWsamples
5892  try:
5893  if BIfalling[0] < BIrising[0]:
5894  bnf1 = BIfalling[1]
5895  else:
5896  bnf1 = BIfalling[0]
5897  except:
5898  bnf1 = 1
5899  else:
5900  try:
5901  bnr1 = BIrising[1]
5902  except:
5903  bnr1 = 0
5904  try:
5905  bnr2 = BIrising[2]
5906  except:
5907  bnr2 = SHOWsamples
5908  try:
5909  if BIfalling[1] < BIrising[1]:
5910  bnf1 = BIfalling[2]
5911  else:
5912  bnf1 = BIfalling[1]
5913  except:
5914  bnf1 = 1
5915  #
5916  CHAHW = float(((anf1 - anr1) * 1000.0) / SAMPLErate)
5917  CHALW = float(((anr2 - anf1) * 1000.0) / SAMPLErate)
5918  CHADCy = float(anf1 - anr1) / float(anr2 - anr1) * 100.0 # in percent
5919  CHBHW = float(((bnf1 - bnr1) * 1000.0) / SAMPLErate)
5920  CHBLW = float(((bnr2 - bnf1) * 1000.0) / SAMPLErate)
5921  CHBDCy = float(bnf1 - bnr1) / float(bnr2 - bnr1) * 100.0 # in percent
5922 #
5923  if bnr1 > anr1:
5924  CHBADelayR1 = float((bnr1 - anr1) * 1000.0 / SAMPLErate)
5925  else:
5926  CHBADelayR1 = float((bnr2 - anr1) * 1000.0 / SAMPLErate)
5927  CHBADelayR2 = float((bnr2 - anr2) * 1000.0 / SAMPLErate)
5928  CHBADelayF = float((bnf1 - anf1) * 1000.0 / SAMPLErate)
5929  try:
5930  CHABphase = 360.0*(float((bnr1 - anr1) * 1000.0 / SAMPLErate))/CHAperiod
5931  except:
5932  CHABphase = 0.0
5933  if CHABphase < 0.0:
5934  CHABphase = CHABphase + 360.0
5935 
5936 def ReInterploateTrigger(TrgBuff):
5937  global DX, TRIGGERsample, TRIGGERlevel
5938 
5939  DX = 0
5940  n = TRIGGERsample
5941  DY = TrgBuff[int(n)] - TrgBuff[int(n+1)]
5942  if DY != 0.0:
5943  DX = (TRIGGERlevel - TrgBuff[int(n+1)])/DY # calculate interpolated trigger point
5944  else:
5945  DX = 0
5946 
5947 def FindTriggerSample(TrgBuff): # find trigger time sample point of passed waveform array
5948  global AutoLevel, TgInput, TRIGGERlevel, TRIGGERentry, DX, SAMPLErate, Is_Triggered
5949  global HoldOffentry, HozPossentry, TRIGGERsample, TRACEsize, HozPoss, hozpos
5950  global Trigger_LPF_length, LPFTrigger
5951 
5952  # Set the TRACEsize variable
5953  TRACEsize = SHOWsamples # Set the trace length
5954  DX = 0
5955  Is_Triggered = 0
5956  if LPFTrigger.get() > 0:
5957  TFiltCoef = [] # empty coef array
5958  for n in range(Trigger_LPF_length.get()):
5959  TFiltCoef.append(float(1.0/Trigger_LPF_length.get()))
5960  TFiltCoef = numpy.array(TFiltCoef)
5961  TrgBuff = numpy.convolve(TrgBuff, TFiltCoef)
5962 
5963  if len(TrgBuff) == 0:
5964  return
5965  try:
5966  TrgMin = numpy.amin(TrgBuff)
5967  except:
5968  TrgMin = 0.0
5969  try:
5970  TrgMax = numpy.amax(TrgBuff)
5971  except:
5972  TrgMax = 0.0
5973 # Find trigger sample
5974  try:
5975  if AutoLevel.get() == 1:
5976  TRIGGERlevel = (TrgMin + TrgMax)/2
5977  TRIGGERentry.delete(0,"end")
5978  TRIGGERentry.insert(0, ' {0:.4f} '.format(TRIGGERlevel))
5979  else:
5980  TRIGGERlevel = eval(TRIGGERentry.get())
5981  except:
5982  TRIGGERentry.delete(0,END)
5983  TRIGGERentry.insert(0, TRIGGERlevel)
5984 # Start from first sample after HoldOff
5985  try:
5986  HoldOff = float(eval(HoldOffentry.get()))
5987  if HoldOff < 0:
5988  HoldOff = 0
5989  HoldOffentry.delete(0,END)
5990  HoldOffentry.insert(0, HoldOff)
5991  except:
5992  HoldOffentry.delete(0,END)
5993  HoldOffentry.insert(0, HoldOff)
5994 # slide trace left right by HozPoss
5995  try:
5996  HozPoss = float(eval(HozPossentry.get()))
5997  except:
5998  HozPossentry.delete(0,END)
5999  HozPossentry.insert(0, HozPoss)
6000 
6001  hldn = int(HoldOff * SAMPLErate/1000)
6002  hozpos = int(HozPoss * SAMPLErate/1000)
6003  if hozpos >= 0:
6004  TRIGGERsample = hldn
6005  else:
6006  TRIGGERsample = abs(hozpos)
6007 #
6008  Nmax = int(TRACEsize / 1.5) # first 2/3 of data set
6009  DX = 0
6010  n = TRIGGERsample
6011  TRIGGERlevel2 = 0.99 * TRIGGERlevel # Hysteresis to avoid triggering on noise
6012  if TRIGGERlevel2 < TrgMin:
6013  TRIGGERlevel2 = TrgMin
6014  if TRIGGERlevel2 > TrgMax:
6015  TRIGGERlevel2 = TrgMax
6016  ChInput = TrgBuff[int(n)]
6017  Prev = ChInput
6018  while ( ChInput >= TRIGGERlevel2) and n < Nmax:
6019  n = n + 1
6020  ChInput = TrgBuff[int(n)]
6021  while (ChInput <= TRIGGERlevel) and n < Nmax:
6022  Prev = ChInput
6023  n = n + 1
6024  ChInput = TrgBuff[int(n)]
6025  DY = ChInput - Prev
6026  if DY != 0.0:
6027  DX = (TRIGGERlevel - Prev)/DY # calculate interpolated trigger point
6028  else:
6029  DX = 0
6030  if TgEdge.get() == 1:
6031  TRIGGERlevel2 = 1.01 * TRIGGERlevel
6032  if TRIGGERlevel2 < TrgMin:
6033  TRIGGERlevel2 = TrgMin
6034  if TRIGGERlevel2 > TrgMax:
6035  TRIGGERlevel2 = TrgMax
6036  ChInput = TrgBuff[int(n)]
6037  Prev = ChInput
6038  while (ChInput <= TRIGGERlevel2) and n < Nmax:
6039  n = n + 1
6040  ChInput = TrgBuff[int(n)]
6041  while (ChInput >= TRIGGERlevel) and n < Nmax:
6042  Prev = ChInput
6043  n = n + 1
6044  ChInput = TrgBuff[int(n)]
6045  DY = Prev - ChInput
6046  try:
6047  DX = (Prev - TRIGGERlevel)/DY # calculate interpolated trigger point
6048  except:
6049  DX = 0
6050 
6051 # check to insure trigger point is in bounds
6052  if n < Nmax:
6053  TRIGGERsample = n - 1
6054  Is_Triggered = 1
6055  elif n > Nmax: # Didn't find edge in first 2/3 of data set
6056  TRIGGERsample = 1 + hldn # reset to begining
6057  Is_Triggered = 0
6058  if DX > 1:
6059  DX = 1 # never more than 100% of a sample period
6060  elif DX < 0:
6061  DX = 0 # never less than 0% of a sample period
6062  if math.isnan(DX):
6063  DX = 0
6064  TRIGGERsample = TRIGGERsample + hozpos
6065 
6066 def DestroyDigScreen():
6067  global win2, DigScreenStatus
6068 
6069  DigScreenStatus.set(0)
6070  win2.destroy()
6071 #
6072 def sel(): # change Digital I/O and update screen color readback
6073  global devx, DevID
6074  global D0, D1, D2, D3, D4, D5, D6, D7
6075  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
6076  global digin0, digin1, digin2, digin3, digin4, digin5, digin6, digin7
6077  # sending 0x50 = set to 0, 0x51 = set to 1
6078  if D0.get() > 0:
6079  devx.ctrl_transfer( 0x40, D0.get(), PIO_0, 0, 0, 0, 100) # set PIO 0
6080  if D0.get() == 0x50:
6081  digin0.configure(text="Low", background="#00ff00")
6082  else:
6083  digin0.configure(text="Hi", background="#ff0000")
6084  else:
6085  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_0, 0, 0, 1, 100)
6086  if Dval[0] == 0:
6087  digin0.configure(text="Low", background="#00ff00")
6088  else:
6089  digin0.configure(text="Hi", background="#ff0000")
6090  if D1.get() > 0:
6091  devx.ctrl_transfer( 0x40, D1.get(), PIO_1, 0, 0, 0, 100) # set PIO 1
6092  if D1.get() == 0x50:
6093  digin1.configure(text="Low", background="#00ff00")
6094  else:
6095  digin1.configure(text="Hi", background="#ff0000")
6096  else:
6097  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100)
6098  if Dval[0] == 0:
6099  digin1.configure(text="Low", background="#00ff00")
6100  else:
6101  digin1.configure(text="Hi", background="#ff0000")
6102  if D2.get() > 0:
6103  devx.ctrl_transfer( 0x40, D2.get(), PIO_2, 0, 0, 0, 100) # set PIO 2
6104  if D2.get() == 0x50:
6105  digin2.configure(text="Low", background="#00ff00")
6106  else:
6107  digin2.configure(text="Hi", background="#ff0000")
6108  else:
6109  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100)
6110  if Dval[0] == 0:
6111  digin2.configure(text="Low", background="#00ff00")
6112  else:
6113  digin2.configure(text="Hi", background="#ff0000")
6114  if D3.get() > 0:
6115  devx.ctrl_transfer( 0x40, D3.get(), PIO_3, 0, 0, 0, 100) # set PIO 3
6116  if D3.get() == 0x50:
6117  digin3.configure(text="Low", background="#00ff00")
6118  else:
6119  digin3.configure(text="Hi", background="#ff0000")
6120  else:
6121  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100)
6122  if Dval[0] == 0:
6123  digin3.configure(text="Low", background="#00ff00")
6124  else:
6125  digin3.configure(text="Hi", background="#ff0000")
6126  if D4.get() > 0:
6127  devx.ctrl_transfer( 0x40, D4.get(), PIO_4, 0, 0, 0, 100) # set PIO 4
6128  if D4.get() == 0x50:
6129  digin4.configure(text="Low", background="#00ff00")
6130  else:
6131  digin4.configure(text="Hi", background="#ff0000")
6132  else:
6133  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100)
6134  if Dval[0] == 0:
6135  digin4.configure(text="Low", background="#00ff00")
6136  else:
6137  digin4.configure(text="Hi", background="#ff0000")
6138  if D5.get() > 0:
6139  devx.ctrl_transfer( 0x40, D5.get(), PIO_5, 0, 0, 0, 100) # set PIO 5
6140  if D5.get() == 0x50:
6141  digin5.configure(text="Low", background="#00ff00")
6142  else:
6143  digin5.configure(text="Hi", background="#ff0000")
6144  else:
6145  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100)
6146  if Dval[0] == 0:
6147  digin5.configure(text="Low", background="#00ff00")
6148  else:
6149  digin5.configure(text="Hi", background="#ff0000")
6150  if D6.get() > 0:
6151  devx.ctrl_transfer( 0x40, D6.get(), PIO_6, 0, 0, 0, 100) # set PIO 6
6152  if D6.get() == 0x50:
6153  digin6.configure(text="Low", background="#00ff00")
6154  else:
6155  digin6.configure(text="Hi", background="#ff0000")
6156  else:
6157  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_6, 0, 0, 1, 100)
6158  if Dval[0] == 0:
6159  digin6.configure(text="Low", background="#00ff00")
6160  else:
6161  digin6.configure(text="Hi", background="#ff0000")
6162  if D7.get() > 0:
6163  devx.ctrl_transfer( 0x40, D7.get(), PIO_7, 0, 0, 0, 100) # set PIO 7
6164  if D7.get() == 0x50:
6165  digin7.configure(text="Low", background="#00ff00")
6166  else:
6167  digin7.configure(text="Hi", background="#ff0000")
6168  else:
6169  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_7, 0, 0, 1, 100)
6170  if Dval[0] == 0:
6171  digin7.configure(text="Low", background="#00ff00")
6172  else:
6173  digin7.configure(text="Hi", background="#ff0000")
6174 
6175 
6176 def MakeDigScreen():
6177  global D0, D1, D2, D3, D4, D5, D6, D7
6178  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
6179  global digin0, digin1, digin2, digin3, digin4, digin5, digin6, digin7
6180  global DigScreenStatus, DacScreenStatus, win2, MuxScreenStatus
6181  # setup Dig output window
6182  if DigScreenStatus.get() == 0 and DacScreenStatus.get() == 0 and MuxScreenStatus.get() == 0:
6183  DigScreenStatus.set(1)
6184  win2 = Toplevel()
6185  win2.title("Dig Out")
6186  win2.resizable(FALSE,FALSE)
6187  win2.protocol("WM_DELETE_WINDOW", DestroyDigScreen)
6188  drb1 = Radiobutton(win2, text="D0-0", variable=D0, value=0x50, command=sel )
6189  drb1.grid(row=2, column=0, sticky=W)
6190  drb0z = Radiobutton(win2, text="D0-Z", variable=D0, value=0, command=sel )
6191  drb0z.grid(row=2, column=1, sticky=W)
6192  drb2 = Radiobutton(win2, text="D0-1", variable=D0, value=0x51, command=sel )
6193  drb2.grid(row=2, column=2, sticky=W)
6194  digin0 = Label(win2, text="Low", background = "#00ff00")
6195  digin0.grid(row=2, column=3, sticky=W)
6196  drb3 = Radiobutton(win2, text="D1-0", variable=D1, value=0x50, command=sel )
6197  drb3.grid(row=3, column=0, sticky=W)
6198  drb3z = Radiobutton(win2, text="D1-Z", variable=D1, value=0, command=sel )
6199  drb3z.grid(row=3, column=1, sticky=W)
6200  drb4 = Radiobutton(win2, text="D1-1", variable=D1, value=0x51, command=sel )
6201  drb4.grid(row=3, column=2, sticky=W)
6202  digin1 = Label(win2, text="Low", background = "#00ff00")
6203  digin1.grid(row=3, column=3, sticky=W)
6204  drb5 = Radiobutton(win2, text="D2-0", variable=D2, value=0x50, command=sel )
6205  drb5.grid(row=4, column=0, sticky=W)
6206  drb5z = Radiobutton(win2, text="D2-Z", variable=D2, value=0, command=sel )
6207  drb5z.grid(row=4, column=1, sticky=W)
6208  drb6 = Radiobutton(win2, text="D2-1", variable=D2, value=0x51, command=sel )
6209  drb6.grid(row=4, column=2, sticky=W)
6210  digin2 = Label(win2, text="Low", background = "#00ff00")
6211  digin2.grid(row=4, column=3, sticky=W)
6212  drb7 = Radiobutton(win2, text="D3-0", variable=D3, value=0x50, command=sel )
6213  drb7.grid(row=5, column=0, sticky=W)
6214  drb7z = Radiobutton(win2, text="D3-Z", variable=D3, value=0, command=sel )
6215  drb7z.grid(row=5, column=1, sticky=W)
6216  drb8 = Radiobutton(win2, text="D3-1", variable=D3, value=0x51, command=sel )
6217  drb8.grid(row=5, column=2, sticky=W)
6218  digin3 = Label(win2, text="Low", background = "#00ff00")
6219  digin3.grid(row=5, column=3, sticky=W)
6220  drb9 = Radiobutton(win2, text="D4-0", variable=D4, value=0x50, command=sel )
6221  drb9.grid(row=6, column=0, sticky=W)
6222  drb9z = Radiobutton(win2, text="D4-Z", variable=D4, value=0, command=sel )
6223  drb9z.grid(row=6, column=1, sticky=W)
6224  drb10 = Radiobutton(win2, text="D4-1", variable=D4, value=0x51, command=sel )
6225  drb10.grid(row=6, column=2, sticky=W)
6226  digin4 = Label(win2, text="Low", background = "#00ff00")
6227  digin4.grid(row=6, column=3, sticky=W)
6228  drb11 = Radiobutton(win2, text="D5-0", variable=D5, value=0x50, command=sel )
6229  drb11.grid(row=7, column=0, sticky=W)
6230  drb11z = Radiobutton(win2, text="D5-Z", variable=D5, value=0, command=sel )
6231  drb11z.grid(row=7, column=1, sticky=W)
6232  drb12 = Radiobutton(win2, text="D5-1", variable=D5, value=0x51, command=sel )
6233  drb12.grid(row=7, column=2, sticky=W)
6234  digin5 = Label(win2, text="Low", background = "#00ff00")
6235  digin5.grid(row=7, column=3, sticky=W)
6236  drb13 = Radiobutton(win2, text="D6-0", variable=D6, value=0x50, command=sel )
6237  drb13.grid(row=8, column=0, sticky=W)
6238  drb13z = Radiobutton(win2, text="D6-Z", variable=D6, value=0, command=sel )
6239  drb13z.grid(row=8, column=1, sticky=W)
6240  drb13 = Radiobutton(win2, text="D6-1", variable=D6, value=0x51, command=sel )
6241  drb13.grid(row=8, column=2, sticky=W)
6242  digin6 = Label(win2, text="Low", background = "#00ff00")
6243  digin6.grid(row=8, column=3, sticky=W)
6244  drb14 = Radiobutton(win2, text="D7-0", variable=D7, value=0x50, command=sel )
6245  drb14.grid(row=9, column=0, sticky=W)
6246  drb14z = Radiobutton(win2, text="D7-Z", variable=D7, value=0, command=sel )
6247  drb14z.grid(row=9, column=1, sticky=W)
6248  drb15 = Radiobutton(win2, text="D7-1", variable=D7, value=0x51, command=sel )
6249  drb15.grid(row=9, column=2, sticky=W)
6250  digin7 = Label(win2, text="Low", background = "#00ff00")
6251  digin7.grid(row=9, column=3, sticky=W)
6252 
6253  digdismissbutton = Button(win2, text="Dismiss", command=DestroyDigScreen)
6254  digdismissbutton.grid(row=10, column=0, sticky=W)
6255 
6256 def DestroyDacScreen():
6257  global win1, DacScreenStatus
6258 
6259  DacScreenStatus.set(0)
6260  win1.destroy()
6261 
6262 def sel0(temp):
6263  global devx, DevID
6264  global PIO_0, PIO_4
6265  global DAC0
6266  # sending 0x50 = set to 0, 0x51 = set to 1
6267  if DAC0.get() == 1:
6268  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 0
6269  devx.ctrl_transfer( 0x40, 0x50, PIO_4, 0, 0, 0, 100) # set PIO 4 0
6270  elif DAC0.get() == 4:
6271  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 0
6272  devx.ctrl_transfer( 0x40, 0x51, PIO_4, 0, 0, 0, 100) # set PIO 4 1
6273  elif DAC0.get() == 2:
6274  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 0
6275  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100) # set PIO 4 Z
6276  elif DAC0.get() == 3:
6277  Dval = devx.ctrl_transfer( 0xc0, 0x91, 0, 0, 0, 1, 100) # set PIO 0 Z
6278  devx.ctrl_transfer( 0x40, 0x50, PIO_4, 0, 0, 0, 100) # set PIO 4
6279  elif DAC0.get() == 5:
6280  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_0, 0, 0, 1, 100) # set PIO 0 Z
6281  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100) # set PIO 4 Z
6282  elif DAC0.get() == 7:
6283  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_0, 0, 0, 1, 100) # set PIO 0 Z
6284  devx.ctrl_transfer( 0x40, 0x51, PIO_4, 0, 0, 0, 100) # set PIO 4 1
6285  elif DAC0.get() == 8:
6286  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0 1
6287  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100) # set PIO 4 Z
6288  elif DAC0.get() == 6:
6289  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0
6290  devx.ctrl_transfer( 0x40, 0x50, PIO_4, 0, 0, 0, 100) # set PIO 4
6291  elif DAC0.get() == 9:
6292  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0
6293  devx.ctrl_transfer( 0x40, 0x51, PIO_4, 0, 0, 0, 100) # set PIO 4
6294 
6295 def sel1(temp):
6296  global devx, DevID
6297  global PIO_1, PIO_5
6298  global DAC1
6299  # sending 0x50 = set to 0, 0x51 = set to 1
6300  if DAC1.get() == 1:
6301  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 0 0
6302  devx.ctrl_transfer( 0x40, 0x50, PIO_5, 0, 0, 0, 100) # set PIO 4 0
6303  elif DAC1.get() == 4:
6304  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 0 0
6305  devx.ctrl_transfer( 0x40, 0x51, PIO_5, 0, 0, 0, 100) # set PIO 4 1
6306  elif DAC1.get() == 2:
6307  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 0 0
6308  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100) # set PIO 4 Z
6309  elif DAC1.get() == 3:
6310  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100) # set PIO 0 Z
6311  devx.ctrl_transfer( 0x40, 0x50, PIO_5, 0, 0, 0, 100) # set PIO 4
6312  elif DAC1.get() == 5:
6313  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100) # set PIO 0 Z
6314  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100) # set PIO 4 Z
6315  elif DAC1.get() == 7:
6316  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100) # set PIO 0 Z
6317  devx.ctrl_transfer( 0x40, 0x51, PIO_5, 0, 0, 0, 100) # set PIO 4 1
6318  elif DAC1.get() == 8:
6319  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 0 1
6320  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100) # set PIO 4 Z
6321  elif DAC1.get() == 6:
6322  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 0
6323  devx.ctrl_transfer( 0x40, 0x50, PIO_5, 0, 0, 0, 100) # set PIO 4
6324  elif DAC1.get() == 9:
6325  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 0
6326  devx.ctrl_transfer( 0x40, 0x51, PIO_5, 0, 0, 0, 100) # set PIO 4
6327 
6328 def sel2(temp):
6329  global devx, DevID
6330  global PIO_2, PIO_6
6331  global DAC2
6332  # sending 0x50 = set to 0, 0x51 = set to 1
6333  if DAC2.get() == 1:
6334  devx.ctrl_transfer( 0x40, 0x50, PIO_2, 0, 0, 0, 100) # set PIO 0 0
6335  devx.ctrl_transfer( 0x40, 0x50, PIO_6, 0, 0, 0, 100) # set PIO 4 0
6336  elif DAC2.get() == 4:
6337  devx.ctrl_transfer( 0x40, 0x50, PIO_2, 0, 0, 0, 100) # set PIO 0 0
6338  devx.ctrl_transfer( 0x40, 0x51, PIO_6, 0, 0, 0, 100) # set PIO 4 1
6339  elif DAC2.get() == 2:
6340  devx.ctrl_transfer( 0x40, 0x50, PIO_2, 0, 0, 0, 100) # set PIO 0 0
6341  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_6, 0, 0, 1, 100) # set PIO 4 Z
6342  elif DAC2.get() == 3:
6343  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100) # set PIO 0 Z
6344  devx.ctrl_transfer( 0x40, 0x50, PIO_6, 0, 0, 0, 100) # set PIO 4
6345  elif DAC2.get() == 5:
6346  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100) # set PIO 0 Z
6347  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_6, 0, 0, 1, 100) # set PIO 4 Z
6348  elif DAC2.get() == 7:
6349  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100) # set PIO 0 Z
6350  devx.ctrl_transfer( 0x40, 0x51, PIO_6, 0, 0, 0, 100) # set PIO 4 1
6351  elif DAC2.get() == 8:
6352  devx.ctrl_transfer( 0x40, 0x51, PIO_2, 0, 0, 0, 100) # set PIO 0 1
6353  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_6, 0, 0, 1, 100) # set PIO 4 Z
6354  elif DAC2.get() == 6:
6355  devx.ctrl_transfer( 0x40, 0x51, PIO_2, 0, 0, 0, 100) # set PIO 0
6356  devx.ctrl_transfer( 0x40, 0x50, PIO_6, 0, 0, 0, 100) # set PIO 4
6357  elif DAC2.get() == 9:
6358  devx.ctrl_transfer( 0x40, 0x51, PIO_2, 0, 0, 0, 100) # set PIO 0
6359  devx.ctrl_transfer( 0x40, 0x51, PIO_6, 0, 0, 0, 100) # set PIO 4
6360 
6361 def sel3(temp):
6362  global devx, DevID
6363  global PIO_3, PIO_7
6364  global DAC3
6365  # sending 0x50 = set to 0, 0x51 = set to 1
6366  if DAC3.get() == 1:
6367  devx.ctrl_transfer( 0x40, 0x50, PIO_3, 0, 0, 0, 100) # set PIO 0 0
6368  devx.ctrl_transfer( 0x40, 0x50, PIO_7, 0, 0, 0, 100) # set PIO 4 0
6369  elif DAC3.get() == 4:
6370  devx.ctrl_transfer( 0x40, 0x50, PIO_3, 0, 0, 0, 100) # set PIO 0 0
6371  devx.ctrl_transfer( 0x40, 0x51, PIO_7, 0, 0, 0, 100) # set PIO 4 1
6372  elif DAC3.get() == 2:
6373  devx.ctrl_transfer( 0x40, 0x50, PIO_3, 0, 0, 0, 100) # set PIO 0 0
6374  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_7, 0, 0, 1, 100) # set PIO 4 Z
6375  elif DAC3.get() == 3:
6376  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100) # set PIO 0 Z
6377  devx.ctrl_transfer( 0x40, 0x50, PIO_7, 0, 0, 0, 100) # set PIO 4
6378  elif DAC3.get() == 5:
6379  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100) # set PIO 0 Z
6380  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_7, 0, 0, 1, 100) # set PIO 4 Z
6381  elif DAC3.get() == 7:
6382  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100) # set PIO 0 Z
6383  devx.ctrl_transfer( 0x40, 0x51, PIO_7, 0, 0, 0, 100) # set PIO 4 1
6384  elif DAC3.get() == 8:
6385  devx.ctrl_transfer( 0x40, 0x51, PIO_3, 0, 0, 0, 100) # set PIO 0 1
6386  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_7, 0, 0, 1, 100) # set PIO 4 Z
6387  elif DAC3.get() == 6:
6388  devx.ctrl_transfer( 0x40, 0x51, PIO_3, 0, 0, 0, 100) # set PIO 0
6389  devx.ctrl_transfer( 0x40, 0x50, PIO_7, 0, 0, 0, 100) # set PIO 4
6390  elif DAC3.get() == 9:
6391  devx.ctrl_transfer( 0x40, 0x51, PIO_3, 0, 0, 0, 100) # set PIO 0
6392  devx.ctrl_transfer( 0x40, 0x51, PIO_7, 0, 0, 0, 100) # set PIO 4
6393 
6394 def MakeDacScreen():
6395  global DAC0, DAC1, DAC2, DAC3, SWRev, RevDate
6396  global DacScreenStatus, DigScreenStatus, win1, MuxScreenStatus
6397  # setup Dig output window
6398  if DacScreenStatus.get() == 0 and DigScreenStatus.get() == 0 and MuxScreenStatus.get() == 0:
6399  DacScreenStatus.set(1)
6400  win1 = Toplevel()
6401  win1.title("DAC Out "+ SWRev + RevDate)
6402  win1.resizable(FALSE,FALSE)
6403  win1.protocol("WM_DELETE_WINDOW", DestroyDacScreen)
6404  DAC0 = Scale(win1, from_=9, to=1, orient=VERTICAL, command=sel0, length=90)
6405  DAC0.grid(row=0, column=0, sticky=W)
6406  DAC1 = Scale(win1, from_=9, to=1, orient=VERTICAL, command=sel1, length=90)
6407  DAC1.grid(row=0, column=1, sticky=W)
6408  DAC2 = Scale(win1, from_=9, to=1, orient=VERTICAL, command=sel2, length=90)
6409  DAC2.grid(row=0, column=2, sticky=W)
6410  DAC3 = Scale(win1, from_=9, to=1, orient=VERTICAL, command=sel3, length=90)
6411  DAC3.grid(row=0, column=3, sticky=W)
6412 
6413  dismissbutton = Button(win1, text="Dismiss", command=DestroyDacScreen)
6414  dismissbutton.grid(row=1, column=0, columnspan=4, sticky=W)
6415 
6416 def UpdateTimeAll():
6417 
6418  MakeTimeTrace() # Update the traces
6419  UpdateTimeScreen() # Update the screen
6420 
6421 def UpdateTimeTrace():
6422 
6423  MakeTimeTrace() # Update traces
6424  UpdateTimeScreen() # Update the screen
6425 
6426 def UpdateTimeScreen():
6427 
6428  MakeTimeScreen() # Update the screen
6429  root.update() # Activate updated screens
6430 
6431 def UpdateXYAll():
6432 
6433  MakeXYTrace() # Update the traces
6434  UpdateXYScreen() # Update the screen
6435 
6436 def UpdateXYTrace():
6437 
6438  MakeXYTrace() # Update traces
6439  UpdateXYScreen() # Update the screen
6440 
6441 def UpdateXYScreen():
6442 
6443  MakeXYScreen() # Update the screen
6444  root.update() # Activate updated screens
6445 
6446 def MakeTimeTrace():
6447  global VBuffA, VBuffB, IBuffA, IBuffB
6448  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, MuxScreenStatus, ChopMuxMode, ChopTrig
6449  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
6450  global VUnAvgA, VUnAvgB, IUnAvgA, IUnAvgB, UnAvgSav
6451  global VmemoryMuxA, VmemoryMuxB, VmemoryMuxC, VmemoryMuxD
6452  global DBuff0, DBuff1, DBuff2, DBuff3, D0, D1, D2, D3
6453  global D0line, D1line, D2line, D3line
6454  global FFTBuffA, FFTBuffB, FFTwindowshape
6455  global AWGAwaveform, AWGBwaveform
6456  global T1Vline, T2Vline, T1Iline, T2Iline
6457  global TMAVline, TMBVline, TMCVline, TMDVline
6458  global Tmathline, TMXline, TMYline
6459  global MathString, MathAxis, MathXString, MathYString, MathXAxis, MathYAxis
6460  global Triggerline, Triggersymbol, TgInput, TgEdge, HoldOff, HoldOffentry
6461  global X0L, Y0T, GRW, GRH, MouseX, MouseY, MouseCAV, MouseCAI, MouseCBV, MouseCBI
6462  global MouseMuxA, MouseMuxB, MouseMuxC, MouseMuxD
6463  global SHOWsamples, ZOHold, AWGBMode
6464  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
6465  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
6466  global Show_MathX, Show_MathY
6467  global TRACES, TRACESread, RUNstatus
6468  global AutoCenterA, AutoCenterB
6469  global CHAsb, CHBsb, CHAOffset, CHBOffset, CHAIsb, CHBIsb, CHAIOffset, CHBIOffset
6470  global TMpdiv # Array with time / div values in ms
6471  global TMsb # Time per div spin box variable
6472  global TIMEdiv # current spin box value
6473  global SAMPLErate, SCstart, Two_X_Sample, DISsamples, First_Slow_sweep
6474  global TRIGGERsample, TRACEsize, DX, TRIGGERsampleAltA, TRIGGERsampleAltB
6475  global TRIGGERlevel, TRIGGERentry, AutoLevel
6476  global InOffA, InGainA, InOffB, InGainB
6477  global CurOffA, CurOffB, CurGainA, CurGainB
6478  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
6479  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
6480  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
6481  global CHAVPosEntry, CHAIPosEntry, CHAVPosEntry, CHBIPosEntry
6482  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
6483  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry
6484  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
6485  global HozPoss, HozPossentry
6486 
6487  # Set the TRACEsize variable
6488  if len(VBuffA) < 100 and MuxScreenStatus.get() == 0:
6489  return
6490  TRACEsize = SHOWsamples # Set the trace length
6491  SCstart = 0
6492  ylo = 0.0
6493  xlo = 0.0
6494  Ymin = Y0T # Minimum position of time grid (top)
6495  Ymax = Y0T + GRH # Maximum position of time grid (bottom)
6496  Xmin = X0L # Minimum position of time grid (left)
6497  Xmax = X0L + GRW # Maximum position of time grid (right)
6498 
6499  # prevent divide by zero error
6500  if TIMEdiv < 0.0002:
6501  TIMEdiv = 0.01
6502  # Check for Auto Centering
6503  if AutoCenterA.get() > 0:
6504  CHAOffset = DCV1
6505  CHAVPosEntry.delete(0,END)
6506  CHAVPosEntry.insert(0, ' {0:.2f} '.format(CHAOffset))
6507  if AutoCenterB.get() > 0:
6508  CHBOffset = DCV2
6509  CHBVPosEntry.delete(0,END)
6510  CHBVPosEntry.insert(0, ' {0:.2f} '.format(CHBOffset))
6511  # get the vertical ranges
6512  try:
6513  CH1pdvRange = float(eval(CHAsb.get()))
6514  except:
6515  CHAsb.delete(0,END)
6516  CHAsb.insert(0, CH1pdvRange)
6517  try:
6518  CH2pdvRange = float(eval(CHBsb.get()))
6519  except:
6520  CHBsb.delete(0,END)
6521  CHBsb.insert(0, CH2pdvRange)
6522  try:
6523  CH1IpdvRange = float(eval(CHAIsb.get()))
6524  except:
6525  CHAIsb.delete(0,END)
6526  CHAIsb.insert(0, CH1IpdvRange)
6527  try:
6528  CH2IpdvRange = float(eval(CHBIsb.get()))
6529  except:
6530  CHBIsb.delete(0,END)
6531  CHBIsb.insert(0, CH2IpdvRange)
6532  # get the vertical offsets
6533  try:
6534  CHAOffset = float(eval(CHAVPosEntry.get()))
6535  except:
6536  CHAVPosEntry.delete(0,END)
6537  CHAVPosEntry.insert(0, CHAOffset)
6538  try:
6539  CHAIOffset = float(eval(CHAIPosEntry.get()))
6540  except:
6541  CHAIPosEntry.delete(0,END)
6542  CHAIPosEntry.insert(0, CHAIOffset)
6543  try:
6544  CHBOffset = float(eval(CHBVPosEntry.get()))
6545  except:
6546  CHBVPosEntry.delete(0,END)
6547  CHBVPosEntry.insert(0, CHBOffset)
6548  try:
6549  CHBIOffset = float(eval(CHBIPosEntry.get()))
6550  except:
6551  CHBIPosEntry.delete(0,END)
6552  CHBIPosEntry.insert(0, CHBIOffset)
6553  # prevent divide by zero error
6554  if CH1pdvRange < 0.001:
6555  CH1pdvRange = 0.001
6556  if CH2pdvRange < 0.001:
6557  CH2pdvRange = 0.001
6558  if CH1IpdvRange < 0.1:
6559  CH1IpdvRange = 0.1
6560  if CH2IpdvRange < 0.1:
6561  CH2IpdvRange = 0.1
6562 #
6563  try:
6564  HoldOff = float(eval(HoldOffentry.get()))
6565  if HoldOff < 0:
6566  HoldOff = 0
6567  HoldOffentry.delete(0,END)
6568  HoldOffentry.insert(0, HoldOff)
6569  except:
6570  HoldOffentry.delete(0,END)
6571  HoldOffentry.insert(0, HoldOff)
6572 #
6573  try:
6574  HozPoss = float(eval(HozPossentry.get()))
6575  except:
6576  HozPossentry.delete(0,END)
6577  HozPossentry.insert(0, HozPoss)
6578 #
6579  hldn = int(HoldOff * SAMPLErate/1000 )
6580  hozpos = int(HozPoss * SAMPLErate/1000 )
6581  if hozpos < 0:
6582  hozpos = 0
6583  # drawing the traces
6584  if TRACEsize == 0: # If no trace, skip rest of this routine
6585  T1Vline = [] # Trace line channel A V
6586  T2Vline = [] # Trace line channel B V
6587  T1Iline = []
6588  T2Iline = []
6589  TMAVline = [] # V Trace line Mux channel A
6590  TMBVline = [] # V Trace line Mux channel B
6591  TMCVline = [] # V Trace line Mux channel C
6592  TMDVline = [] # V Trace line Mux channel D
6593  Tmathline = [] # math trce line
6594  return()
6595 
6596  # set and/or corrected for in range
6597  if TgInput.get() > 0 or ChopTrig.get() > 0:
6598  SCmin = int(-1 * TRIGGERsample)
6599  SCmax = int(TRACEsize - TRIGGERsample - 0)
6600  else:
6601  SCmin = 0 # hldn
6602  SCmax = TRACEsize - 1
6603  if SCstart < SCmin: # No reading before start of array
6604  SCstart = SCmin
6605  if SCstart > SCmax: # No reading after end of array
6606  SCstart = SCmax
6607 
6608  # Make Trace lines etc.
6609 
6610  Yconv1 = float(GRH/10.0) / CH1pdvRange # Vertical Conversion factors from samples to screen points
6611  Yconv2 = float(GRH/10.0) / CH2pdvRange
6612  YIconv1 = float(GRH/10.0) / CH1IpdvRange
6613  YIconv2 = float(GRH/10.0) / CH2IpdvRange
6614  Xconv1 = float(GRW/10.0) / CH1pdvRange # Horizontal Conversion factors from samples to screen points
6615  Xconv2 = float(GRW/10.0) / CH2pdvRange
6616  XIconv1 = float(GRW/10.0) / CH1IpdvRange
6617  XIconv2 = float(GRW/10.0) / CH2IpdvRange
6618  if MuxScreenStatus.get() == 1: # if using analog Mux set up axis controls
6619  try:
6620  CHMApdvRange = float(eval(CHB_Asb.get()))
6621  except:
6622  CHB_Asb.delete(0,END)
6623  CHB_Asb.insert(0, CHMApdvRange)
6624  try:
6625  CHMBpdvRange = float(eval(CHB_Bsb.get()))
6626  except:
6627  CHB_Bsb.delete(0,END)
6628  CHB_Bsb.insert(0, CHMBpdvRange)
6629  try:
6630  CHMCpdvRange = float(eval(CHB_Csb.get()))
6631  except:
6632  CHB_Csb.delete(0,END)
6633  CHB_Csb.insert(0, CHMCpdvRange)
6634  try:
6635  CHMDpdvRange = float(eval(CHB_Dsb.get()))
6636  except:
6637  CHB_Dsb.delete(0,END)
6638  CHB_Dsb.insert(0, CHMDpdvRange)
6639  YconvMA = float(GRH/10.0) / CHMApdvRange
6640  YconvMB = float(GRH/10.0) / CHMBpdvRange
6641  YconvMC = float(GRH/10.0) / CHMCpdvRange
6642  YconvMD = float(GRH/10.0) / CHMDpdvRange
6643  try:
6644  CHBAOffset = float(eval(CHB_APosEntry.get()))
6645  except:
6646  CHB_APosEntry.delete(0,END)
6647  CHB_APosEntry.insert(0, CHBAOffset)
6648  try:
6649  CHBBOffset = float(eval(CHB_BPosEntry.get()))
6650  except:
6651  CHB_BPosEntry.delete(0,END)
6652  CHB_BPosEntry.insert(0, CHBBOffset)
6653  try:
6654  CHBCOffset = float(eval(CHB_CPosEntry.get()))
6655  except:
6656  CHB_CPosEntry.delete(0,END)
6657  CHB_CPosEntry.insert(0, CHBCOffset)
6658  try:
6659  CHBDOffset = float(eval(CHB_DPosEntry.get()))
6660  except:
6661  CHB_DPosEntry.delete(0,END)
6662  CHB_DPosEntry.insert(0, CHBDOffset)
6663  if MathAxis == "V-A":
6664  YconvM = Yconv1
6665  CHMOffset = CHAOffset
6666  elif MathAxis == "V-B":
6667  YconvM = Yconv2
6668  CHMOffset = CHBOffset
6669  elif MathAxis == "I-A":
6670  YconvM = YIconv1
6671  CHMOffset = CHAIOffset
6672  elif MathAxis == "I-B":
6673  YconvM = YIconv2
6674  CHMOffset = CHBIOffset
6675  else:
6676  YconvM = Yconv1
6677  CHMOffset = CHAOffset
6678 # include ploting X and Y math formulas vs time
6679  if MathYAxis == "V-A":
6680  YconvMxy = Yconv1
6681  CHMYOffset = CHAOffset
6682  elif MathYAxis == "V-B":
6683  YconvMxy = Yconv2
6684  CHMYOffset = CHBOffset
6685  elif MathYAxis == "I-A":
6686  YconvMxy = YIconv1
6687  CHMYOffset = CHAIOffset
6688  elif MathYAxis == "I-B":
6689  YconvMxy = YIconv2
6690  CHMYOffset = CHBIOffset
6691  else:
6692  YconvMxy = Yconv1
6693  CHMYOffset = CHAOffset
6694 #
6695  if MathXAxis == "V-A":
6696  XconvMxy = Yconv1
6697  CHMXOffset = CHAOffset
6698  elif MathXAxis == "V-B":
6699  XconvMxy = Yconv2
6700  CHMXOffset = CHBOffset
6701  elif MathXAxis == "I-A":
6702  XconvMxy = YIconv1
6703  CHMXOffset = CHAIOffset
6704  elif MathXAxis == "I-B":
6705  XconvMxy = YIconv2
6706  CHMXOffset = CHBIOffset
6707  else:
6708  XconvMxy = Yconv1
6709  CHMXOffset = CHAOffset
6710 #
6711  c1 = GRH / 2.0 + Y0T # fixed correction channel A
6712  c2 = GRH / 2.0 + Y0T # fixed correction channel B
6713 
6714  if First_Slow_sweep == 1:
6715  TRACEsize = len(VBuffA)
6716  DISsamples = GRW
6717  D0line = []
6718  D1line = []
6719  D2line = []
6720  D3line = []
6721  Dconv = float(GRH/10.0) # pixels per Div
6722  else:
6723  DISsamples = SAMPLErate * 10.0 * TIMEdiv / 1000.0 # number of samples to display
6724  T1Vline = [] # V Trace line channel A
6725  T2Vline = [] # V Trace line channel B
6726  T1Iline = [] # I Trace line channel A
6727  T2Iline = [] # I Trace line channel B
6728  TMAVline = [] # V Trace line Mux channel A
6729  TMBVline = [] # V Trace line Mux channel B
6730  TMCVline = [] # V Trace line Mux channel C
6731  TMDVline = [] # V Trace line Mux channel D
6732  Tmathline = [] # math trce line
6733  TMXline = [] # X math Trace line
6734  TMYline = [] # Y math Trace line
6735  if len(VBuffA) < 4 and len(VBuffB) < 4 and len(IBuffA) < 4 and len(IBuffB) < 4:
6736  return
6737  t = int(SCstart + TRIGGERsample) # - (TriggerPos * SAMPLErate) # t = Start sample in trace
6738  if t < 0:
6739  t = 0
6740  x = 0 # Horizontal screen pixel
6741 #
6742  ypv1 = int(c1 - Yconv1 * (VBuffA[t] - CHAOffset))
6743  ypi1 = int(c1 - YIconv1 * (IBuffA[t] - CHAIOffset))
6744  ypv2 = int(c2 - Yconv2 * (VBuffB[t] - CHBOffset))
6745  ypi2 = int(c1 - YIconv2 * (IBuffB[t] - CHBIOffset))
6746  DvY1 = DvY2 = DiY1 = DiY2 = 0
6747 #
6748  if (DISsamples <= GRW):
6749  Xstep = GRW / DISsamples
6750  if AWGBMode.get() == 2 and Two_X_Sample.get() == 0:
6751  xa = int((Xstep/-2.5) - (Xstep*DX))
6752  else:
6753  xa = 0 - int(Xstep*DX) # adjust start pixel for interpolated trigger point
6754  x = 0 - int(Xstep*DX)
6755  Tstep = 1
6756  x1 = 0 # x position of trace line
6757  xa1 = 0
6758  y1 = 0.0 # y position of trace line
6759  ypv1 = int(c1 - Yconv1 * (VBuffA[t] - CHAOffset))
6760  ytemp = IBuffA[t]
6761  ypi1 = int(c1 - YIconv1 * (ytemp - CHAIOffset))
6762  ypv2 = int(c2 - Yconv2 * (VBuffB[t] - CHBOffset))
6763  if MuxScreenStatus.get() == 1:
6764  if len(VBuffMA) > 4:
6765  ypvma = int(c2 - YconvMA * (VBuffMA[t] - CHBAOffset))
6766  if len(VBuffMB) > 4:
6767  ypvmb = int(c2 - YconvMB * (VBuffMB[t] - CHBBOffset))
6768  if len(VBuffMC) > 4:
6769  ypvmc = int(c2 - YconvMC * (VBuffMC[t] - CHBCOffset))
6770  if len(VBuffMD) > 4:
6771  ypvmd = int(c2 - YconvMD * (VBuffMD[t] - CHBDOffset))
6772  ytemp = IBuffB[t]
6773  ypi2 = int(c1 - YIconv2 * (ytemp - CHBIOffset))
6774  ypm = ypmx = ypmy = GRH / 2.0 + Y0T
6775  if TgInput.get() == 0:
6776  Xlimit = GRW
6777  else:
6778  Xlimit = GRW+Xstep
6779  while x <= Xlimit:
6780  if t < TRACEsize:
6781  xa1 = xa + X0L
6782  x1 = x + X0L
6783  y1 = int(c1 - Yconv1 * (VBuffA[t] - CHAOffset))
6784  ytemp = IBuffA[t]
6785  yi1 = int(c1 - YIconv1 * (ytemp - CHAIOffset))
6786 
6787  if y1 < Ymin: # clip waveform if going off grid
6788  y1 = Ymin
6789  if y1 > Ymax:
6790  y1 = Ymax
6791  if yi1 < Ymin:
6792  yi1 = Ymin
6793  if yi1 > Ymax:
6794  yi1 = Ymax
6795  if ShowC1_V.get() == 1 :
6796  if ZOHold.get() == 1:
6797  T1Vline.append(int(xa1))
6798  T1Vline.append(int(ypv1))
6799  T1Vline.append(int(xa1))
6800  T1Vline.append(int(y1))
6801  else:
6802  T1Vline.append(int(xa1))
6803  T1Vline.append(int(y1))
6804  DvY1 = ypv1 - y1
6805  ypv1 = y1
6806  if ShowC1_I.get() == 1:
6807  if ZOHold.get() == 1:
6808  T1Iline.append(int(xa1))
6809  T1Iline.append(int(ypi1))
6810  T1Iline.append(int(xa1))
6811  T1Iline.append(int(yi1))
6812  else:
6813  T1Iline.append(int(xa1))
6814  T1Iline.append(int(yi1))
6815  DiY1 = ypi1 - yi1
6816  ypi1 = yi1
6817  if ShowC2_V.get() == 1:
6818  y1 = int(c2 - Yconv2 * (VBuffB[t] - CHBOffset))
6819  if y1 < Ymin: # clip waveform if going off grid
6820  y1 = Ymin
6821  if y1 > Ymax:
6822  y1 = Ymax
6823  if ZOHold.get() == 1:
6824  T2Vline.append(int(x1))
6825  T2Vline.append(int(ypv2))
6826  T2Vline.append(int(x1))
6827  T2Vline.append(int(y1))
6828  else:
6829  T2Vline.append(int(x1))
6830  T2Vline.append(int(y1))
6831  DvY2 = ypv2 - y1
6832  ypv2 = y1
6833  if Show_CBA.get() == 1 and MuxScreenStatus.get() == 1 and len(VBuffMA)>4:
6834  y1 = int(c2 - YconvMA * (VBuffMA[t] - CHBAOffset))
6835  if y1 < Ymin: # clip waveform if going off grid
6836  y1 = Ymin
6837  if y1 > Ymax:
6838  y1 = Ymax
6839  if ZOHold.get() == 1:
6840  TMAVline.append(int(x1))
6841  TMAVline.append(int(ypvma))
6842  TMAVline.append(int(x1))
6843  TMAVline.append(int(y1))
6844  else:
6845  TMAVline.append(int(x1))
6846  TMAVline.append(int(y1))
6847  ypvma = y1
6848  if (MouseX - X0L) >= x and (MouseX - X0L) < (x + Xstep):
6849  Xfine = MouseX - X0L - x
6850  MouseMuxA = ypvma - (y1 - ypvma) * (Xfine/Xstep)
6851  if Show_CBB.get() == 1 and MuxScreenStatus.get() == 1 and len(VBuffMB)>4:
6852  y1 = int(c2 - YconvMB * (VBuffMB[t] - CHBBOffset))
6853  if y1 < Ymin: # clip waveform if going off grid
6854  y1 = Ymin
6855  if y1 > Ymax:
6856  y1 = Ymax
6857  if ZOHold.get() == 1:
6858  TMBVline.append(int(x1))
6859  TMBVline.append(int(ypvmb))
6860  TMBVline.append(int(x1))
6861  TMBVline.append(int(y1))
6862  else:
6863  TMBVline.append(int(x1))
6864  TMBVline.append(int(y1))
6865  ypvmb = y1
6866  if (MouseX - X0L) >= x and (MouseX - X0L) < (x + Xstep):
6867  Xfine = MouseX - X0L - x
6868  MouseMuxB = ypvmb - (y1 - ypvmb) * (Xfine/Xstep)
6869  if Show_CBC.get() == 1 and MuxScreenStatus.get() == 1 and len(VBuffMC)>4:
6870  y1 = int(c2 - YconvMC * (VBuffMC[t] - CHBCOffset))
6871  if y1 < Ymin: # clip waveform if going off grid
6872  y1 = Ymin
6873  if y1 > Ymax:
6874  y1 = Ymax
6875  if ZOHold.get() == 1:
6876  TMCVline.append(int(x1))
6877  TMCVline.append(int(ypvmc))
6878  TMCVline.append(int(x1))
6879  TMCVline.append(int(y1))
6880  else:
6881  TMCVline.append(int(x1))
6882  TMCVline.append(int(y1))
6883  ypvmc = y1
6884  if (MouseX - X0L) >= x and (MouseX - X0L) < (x + Xstep):
6885  Xfine = MouseX - X0L - x
6886  MouseMuxC = ypvmc - (y1 - ypvmc) * (Xfine/Xstep)
6887  if Show_CBD.get() == 1 and MuxScreenStatus.get() == 1 and len(VBuffMD)>4:
6888  y1 = int(c2 - YconvMD * (VBuffMD[t] - CHBDOffset))
6889  if y1 < Ymin: # clip waveform if going off grid
6890  y1 = Ymin
6891  if y1 > Ymax:
6892  y1 = Ymax
6893  if ZOHold.get() == 1:
6894  TMDVline.append(int(x1))
6895  TMDVline.append(int(ypvmd))
6896  TMDVline.append(int(x1))
6897  TMDVline.append(int(y1))
6898  else:
6899  TMDVline.append(int(x1))
6900  TMDVline.append(int(y1))
6901  ypvmd = y1
6902  if (MouseX - X0L) >= x and (MouseX - X0L) < (x + Xstep):
6903  Xfine = MouseX - X0L - x
6904  MouseMuxD = ypvmd - (y1 - ypvmd) * (Xfine/Xstep)
6905  if ShowC2_I.get() == 1:
6906  ytemp = IBuffB[t]
6907  yi1 = int(c1 - YIconv2 * (ytemp - CHBIOffset))
6908  if yi1 < Ymin:
6909  yi1 = Ymin
6910  if yi1 > Ymax:
6911  yi1 = Ymax
6912  if (ZOHold.get() == 1):
6913  T2Iline.append(int(x1))
6914  T2Iline.append(int(ypi2))
6915  T2Iline.append(int(x1))
6916  T2Iline.append(int(yi1))
6917  else:
6918  T2Iline.append(int(x1))
6919  T2Iline.append(int(yi1))
6920  DiY2 = ypi2 - yi1
6921  ypi2 = yi1
6922  if MathTrace.get() > 0:
6923  if MathTrace.get() == 1: # plot sum of CA-V and CB-V
6924  y1 = int(c1 - Yconv1 * (VBuffA[t] + VBuffB[t] - CHAOffset))
6925 
6926  elif MathTrace.get() == 2: # plot difference of CA-V and CB-V
6927  y1 = int(c1 - Yconv1 * (VBuffA[t] - VBuffB[t] - CHAOffset))
6928 
6929  elif MathTrace.get() == 3: # plot difference of CB-V and CA-V
6930  y1 = int(c2 - Yconv2 * (VBuffB[t] - VBuffA[t] - CHBOffset))
6931 
6932  elif MathTrace.get() == 4: # plot product of CA-V and CA-I
6933  Ypower = VBuffA[t] * IBuffA[t] # mAmps * Volts = mWatts
6934  ytemp = YIconv1 * (Ypower - CHAIOffset)
6935  y1 = int(c1 - ytemp)
6936 
6937  elif MathTrace.get() == 5: # plot product of CB-V and CB-I
6938  Ypower = VBuffB[t] * IBuffB[t] # mAmps * Volts = mWatts
6939  ytemp = YIconv2 * (Ypower - CHBIOffset)
6940  y1 = int(c2 - ytemp)
6941 
6942  elif MathTrace.get() == 6: # plot ratio of CA-V and CA-I
6943  Yohms = VBuffA[t] / (IBuffA[t] / 1000.0) # Volts / Amps = ohms
6944  ytemp = YIconv1 * (Yohms - CHAIOffset)
6945  y1 = int(c1 - ytemp)
6946 
6947  elif MathTrace.get() == 7: # plot ratio of CB-V and CB-I
6948  Yohms = VBuffB[t] / (IBuffB[t] / 1000.0) # Volts / Amps = ohms
6949  ytemp = YIconv2 * (Yohms - CHBIOffset)
6950  y1 = int(c2 - ytemp)
6951 
6952  elif MathTrace.get() == 8: # plot difference of CA-I and CB-I
6953  Ydif = (IBuffA[t] - IBuffB[t])# in mA
6954  ytemp = YIconv1 * (Ydif - CHAIOffset)
6955  y1 = int(c2 - ytemp)
6956 
6957  elif MathTrace.get() == 9: # plot difference of CB-I and CA-I
6958  Ydif = (IBuffB[t] - IBuffA[t]) # in mA
6959  ytemp = YIconv2 * (Ydif - CHBIOffset)
6960  y1 = int(c2 - ytemp)
6961 
6962  elif MathTrace.get() == 10: # plot ratio of CB-V and CA-V
6963  try:
6964  y1 = int(c1 - Yconv2 * ((VBuffB[t] / VBuffA[t]) - CHBOffset)) # voltage gain A to B
6965  except:
6966  y1 = int(c1 - Yconv2 * ((VBuffB[t] / 0.000001) - CHBOffset))
6967 
6968  elif MathTrace.get() == 11: # plot ratio of CB-I and CA-I
6969  try:
6970  Y1 = (IBuffB[t] / IBuffA[t]) # current gain A to B
6971  except:
6972  Y1 = (IBuffB[t] / 0.000001)
6973  ytemp = YIconv2 * (Y1 - CHBIOffset)
6974  y1 = int(c2 - ytemp)
6975 
6976  elif MathTrace.get() == 12: # plot from equation string
6977  # MathString = "(VBuffA[t]+ VBuffB[t] - CHAOffset)"
6978  try:
6979  MathResult = eval(MathString)
6980  MathResult = MathResult - CHMOffset
6981  y1 = int(c1 - YconvM * MathResult)
6982  except:
6983  RUNstatus.set(0)
6984  x = Xlimit + 1 # exit loop
6985 
6986  if y1 < Ymin: # clip waveform if going off grid
6987  y1 = Ymin
6988  if y1 > Ymax:
6989  y1 = Ymax
6990  if ZOHold.get() == 1: # connet the dots with stair step
6991  Tmathline.append(int(x1))
6992  Tmathline.append(int(ypm))
6993  Tmathline.append(int(x1))
6994  Tmathline.append(int(y1))
6995  else: # connet the dots with single line
6996  Tmathline.append(int(x1))
6997  Tmathline.append(int(y1))
6998  ypm = y1
6999  if Show_MathX.get() > 0:
7000  try:
7001  MathResult = eval(MathXString)
7002  MathResult = MathResult - CHMXOffset
7003  y1 = int(c1 - XconvMxy * MathResult)
7004  except:
7005  RUNstatus.set(0)
7006  x = Xlimit + 1 # exit loop
7007 
7008  if y1 < Ymin: # clip waveform if going off grid
7009  y1 = Ymin
7010  if y1 > Ymax:
7011  y1 = Ymax
7012  if ZOHold.get() == 1: # connet the dots with stair step
7013  TMXline.append(int(x1))
7014  TMXline.append(int(ypmx))
7015  TMXline.append(int(x1))
7016  TMXline.append(int(y1))
7017  else: # connet the dots with single line
7018  TMXline.append(int(x1))
7019  TMXline.append(int(y1))
7020  ypmx = y1
7021  if Show_MathY.get() > 0:
7022  try:
7023  MathResult = eval(MathYString)
7024  MathResult = MathResult - CHMYOffset
7025  y1 = int(c1 - YconvMxy * MathResult)
7026  except:
7027  RUNstatus.set(0)
7028  x = Xlimit + 1 # exit loop
7029 
7030  if y1 < Ymin: # clip waveform if going off grid
7031  y1 = Ymin
7032  if y1 > Ymax:
7033  y1 = Ymax
7034  if ZOHold.get() == 1: # connet the dots with stair step
7035  TMYline.append(int(x1))
7036  TMYline.append(int(ypmy))
7037  TMYline.append(int(x1))
7038  TMYline.append(int(y1))
7039  else: # connet the dots with single line
7040  TMYline.append(int(x1))
7041  TMYline.append(int(y1))
7042  ypmy = y1
7043  if D0.get() == 0:
7044  yd = int(c1 - (( DBuff0[t]*0.9 - 5 ) * Dconv))
7045  D0line.append(int(x1))
7046  D0line.append(yd)
7047  if D1.get() == 0:
7048  yd = int(c1 - (( DBuff1[t]*0.9 - 4 ) * Dconv))
7049  D1line.append(int(x1))
7050  D1line.append(yd)
7051  if D2.get() == 0:
7052  yd = int(c1 - (( DBuff2[t]*0.9 - 3 ) * Dconv))
7053  D2line.append(int(x1))
7054  D2line.append(yd)
7055  if D3.get() == 0:
7056  yd = int(c1 - (( DBuff3[t]*0.9 - 2 ) * Dconv))
7057  D3line.append(int(x1))
7058  D3line.append(yd)
7059 
7060  # remember trace verticle pixel at X mouse location
7061  if MouseX - X0L >= x and MouseX - X0L < (x + Xstep): # - Xstep
7062  Xfine = MouseX - X0L - x
7063  MouseCAV = ypv1 - (DvY1 * (Xfine/Xstep)) # interpolate along yaxis
7064  MouseCAI = ypi1 - (DiY1 * (Xfine/Xstep))
7065  MouseCBV = ypv2 - (DvY2 * (Xfine/Xstep))
7066  MouseCBI = ypi2 - (DiY2 * (Xfine/Xstep))
7067  t = int(t + Tstep)
7068  x = x + Xstep
7069  xa = xa + Xstep
7070 
7071  else: #if (DISsamples > GRW): # if the number of samples is larger than the grid width need to ship over samples
7072  Xstep = 1
7073  Tstep = DISsamples / GRW # number of samples to skip per grid pixel
7074  x1 = 0.0 # x position of trace line
7075  ylo = 0.0 # ymin position of trace 1 line
7076  yhi = 0.0 # ymax position of trace 1 line
7077 
7078  t = int(SCstart + TRIGGERsample) # - (TriggerPos * SAMPLErate) # t = Start sample in trace
7079  if t > len(VBuffA)-1:
7080  t = 0
7081  if t < 0:
7082  t = 0
7083  x = 0 # Horizontal screen pixel
7084  ft = t # time point with fractions
7085  while (x <= GRW):
7086  if (t < TRACEsize):
7087  if (t >= len(VBuffA)):
7088  t = len(VBuffA)-2
7089  x = GRW
7090  x1 = x + X0L
7091  ylo = VBuffA[t] - CHAOffset
7092  ilo = IBuffA[t] - CHAIOffset
7093  yhi = ylo
7094  ihi = ilo
7095  n = t
7096  while n < (t + Tstep) and n < TRACEsize:
7097  if ( ShowC1_V.get() == 1 ):
7098  v = VBuffA[t] - CHAOffset
7099  if v < ylo:
7100  ylo = v
7101  if v > yhi:
7102  yhi = v
7103  if ( ShowC1_I.get() == 1 ):
7104  i = IBuffA[t] - CHAIOffset
7105  if i < ilo:
7106  ilo = i
7107  if i > ihi:
7108  ihi = i
7109  n = n + 1
7110  if ( ShowC1_V.get() == 1 ):
7111  ylo = int(c1 - Yconv1 * ylo)
7112  yhi = int(c1 - Yconv1 * yhi)
7113  if (ylo < Ymin):
7114  ylo = Ymin
7115  if (ylo > Ymax):
7116  ylo = Ymax
7117  if (yhi < Ymin):
7118  yhi = Ymin
7119  if (yhi > Ymax):
7120  yhi = Ymax
7121  T1Vline.append(int(x1))
7122  T1Vline.append(int(ylo))
7123  T1Vline.append(int(x1))
7124  T1Vline.append(int(yhi))
7125  ypv1 = ylo
7126  if ( ShowC1_I.get() == 1 ):
7127  ilo = int(c1 - YIconv1 * ilo)
7128  ihi = int(c1 - YIconv1 * ihi)
7129  if (ilo < Ymin):
7130  ilo = Ymin
7131  if (ilo > Ymax):
7132  ilo = Ymax
7133  if (ihi < Ymin):
7134  ihi = Ymin
7135  if (ihi > Ymax):
7136  ihi = Ymax
7137  T1Iline.append(int(x1))
7138  T1Iline.append(int(ilo))
7139  T1Iline.append(int(x1))
7140  T1Iline.append(int(ihi))
7141  ypi1 = ilo
7142  ylo = VBuffB[t] - CHBOffset
7143  ilo = IBuffB[t] - CHBIOffset
7144  yhi = ylo
7145  ihi = ilo
7146  n = t
7147  if MuxScreenStatus.get() == 0:
7148  while n < (t + Tstep) and n < TRACEsize:
7149  if ( ShowC2_V.get() == 1 ):
7150  v = VBuffB[t] - CHBOffset
7151  if v < ylo:
7152  ylo = v
7153  if v > yhi:
7154  yhi = v
7155  if ( ShowC2_I.get() == 1 ):
7156  i = IBuffB[t] - CHBIOffset
7157  if i < ilo:
7158  ilo = i
7159  if i > ihi:
7160  ihi = i
7161  n = n + 1
7162  if ( ShowC2_V.get() == 1 ):
7163  ylo = int(c2 - Yconv2 * ylo)
7164  yhi = int(c2 - Yconv2 * yhi)
7165  if (ylo < Ymin):
7166  ylo = Ymin
7167  if (ylo > Ymax):
7168  ylo = Ymax
7169 
7170  if (yhi < Ymin):
7171  yhi = Ymin
7172  if (yhi > Ymax):
7173  yhi = Ymax
7174  T2Vline.append(int(x1))
7175  T2Vline.append(int(ylo))
7176  T2Vline.append(int(x1))
7177  T2Vline.append(int(yhi))
7178  ypv2 = ylo
7179  if ( ShowC2_I.get() == 1 ):
7180  ilo = int(c2 - YIconv2 * ilo)
7181  ihi = int(c2 - YIconv2 * ihi)
7182  if (ilo < Ymin):
7183  ilo = Ymin
7184  if (ilo > Ymax):
7185  ilo = Ymax
7186  if (ihi < Ymin):
7187  ihi = Ymin
7188  if (ihi > Ymax):
7189  ihi = Ymax
7190  T2Iline.append(int(x1))
7191  T2Iline.append(int(ilo))
7192  T2Iline.append(int(x1))
7193  T2Iline.append(int(ihi))
7194  ypi2 = ilo
7195  else:
7196  if Show_CBA.get() == 1 and len(VBuffMA)>4:
7197  if t < len(VBuffMA):
7198  ylo = VBuffMA[t] - CHBAOffset
7199  yhi = ylo
7200  n = t
7201  while n < (t + Tstep) and n < len(VBuffMA):
7202  v = VBuffMA[t] - CHBAOffset
7203  if v < ylo:
7204  ylo = v
7205  if v > yhi:
7206  yhi = v
7207  n = n + 1
7208  ylo = int(c2 - YconvMA * ylo)
7209  yhi = int(c2 - YconvMA * yhi)
7210  if (ylo < Ymin):
7211  ylo = Ymin
7212  if (ylo > Ymax):
7213  ylo = Ymax
7214  if (yhi < Ymin):
7215  yhi = Ymin
7216  if (yhi > Ymax):
7217  yhi = Ymax
7218  TMAVline.append(int(x1))
7219  TMAVline.append(int(ylo))
7220  TMAVline.append(int(x1))
7221  TMAVline.append(int(yhi))
7222  if (MouseX - X0L) > (x - Xstep) and (MouseX - X0L) < (x + Xstep):
7223  MouseMuxA = ylo
7224  if Show_CBB.get() == 1 and len(VBuffMB)>4:
7225  if t < len(VBuffMB):
7226  ylo = VBuffMB[t] - CHBBOffset
7227  yhi = ylo
7228  n = t
7229  while n < (t + Tstep) and n < len(VBuffMB):
7230  v = VBuffMB[t] - CHBBOffset
7231  if v < ylo:
7232  ylo = v
7233  if v > yhi:
7234  yhi = v
7235  n = n + 1
7236  ylo = int(c2 - YconvMB * ylo)
7237  yhi = int(c2 - YconvMB * yhi)
7238  if (ylo < Ymin):
7239  ylo = Ymin
7240  if (ylo > Ymax):
7241  ylo = Ymax
7242  if (yhi < Ymin):
7243  yhi = Ymin
7244  if (yhi > Ymax):
7245  yhi = Ymax
7246  TMBVline.append(int(x1))
7247  TMBVline.append(int(ylo))
7248  TMBVline.append(int(x1))
7249  TMBVline.append(int(yhi))
7250  if (MouseX - X0L) > (x - Xstep) and (MouseX - X0L) < (x + Xstep):
7251  MouseMuxB = ylo
7252  if Show_CBC.get() == 1 and len(VBuffMC)>4:
7253  if t < len(VBuffMC):
7254  ylo = VBuffMC[t] - CHBCOffset
7255  yhi = ylo
7256  n = t
7257  while n < (t + Tstep) and n < len(VBuffMC):
7258  v = VBuffMC[t] - CHBCOffset
7259  if v < ylo:
7260  ylo = v
7261  if v > yhi:
7262  yhi = v
7263  n = n + 1
7264  ylo = int(c2 - YconvMC * ylo)
7265  yhi = int(c2 - YconvMC * yhi)
7266  if (ylo < Ymin):
7267  ylo = Ymin
7268  if (ylo > Ymax):
7269  ylo = Ymax
7270  if (yhi < Ymin):
7271  yhi = Ymin
7272  if (yhi > Ymax):
7273  yhi = Ymax
7274  TMCVline.append(int(x1))
7275  TMCVline.append(int(ylo))
7276  TMCVline.append(int(x1))
7277  TMCVline.append(int(yhi))
7278  if (MouseX - X0L) > (x - Xstep) and (MouseX - X0L) < (x + Xstep):
7279  MouseMuxC = ylo
7280  if Show_CBD.get() == 1 and len(VBuffMD)>4:
7281  if t < len(VBuffMD):
7282  ylo = VBuffMD[t] - CHBDOffset
7283  yhi = ylo
7284  n = t
7285  while n < (t + Tstep) and n < len(VBuffMD):
7286  v = VBuffMD[t] - CHBDOffset
7287  if v < ylo:
7288  ylo = v
7289  if v > yhi:
7290  yhi = v
7291  n = n + 1
7292  ylo = int(c2 - YconvMD * ylo)
7293  yhi = int(c2 - YconvMD * yhi)
7294  if (ylo < Ymin):
7295  ylo = Ymin
7296  if (ylo > Ymax):
7297  ylo = Ymax
7298  if (yhi < Ymin):
7299  yhi = Ymin
7300  if (yhi > Ymax):
7301  yhi = Ymax
7302  TMDVline.append(int(x1))
7303  TMDVline.append(int(ylo))
7304  TMDVline.append(int(x1))
7305  TMDVline.append(int(yhi))
7306  if (MouseX - X0L) > (x - Xstep) and (MouseX - X0L) < (x + Xstep):
7307  MouseMuxD = ylo
7308  if ( ShowC2_I.get() == 1 ):
7309  while n < (t + Tstep) and n < TRACEsize:
7310  i = IBuffB[t] - CHBIOffset
7311  if i < ilo:
7312  ilo = i
7313  if i > ihi:
7314  ihi = i
7315  n = n + 1
7316  ilo = int(c2 - YIconv2 * ilo)
7317  ihi = int(c2 - YIconv2 * ihi)
7318  if (ilo < Ymin):
7319  ilo = Ymin
7320  if (ilo > Ymax):
7321  ilo = Ymax
7322  if (ihi < Ymin):
7323  ihi = Ymin
7324  if (ihi > Ymax):
7325  ihi = Ymax
7326  T2Iline.append(int(x1))
7327  T2Iline.append(int(ilo))
7328  T2Iline.append(int(x1))
7329  T2Iline.append(int(ihi))
7330  if MathTrace.get() > 0:
7331  if MathTrace.get() == 1: # plot sum of CA-V and CB-V
7332  y1 = int(c1 - Yconv1 * (VBuffA[t] + VBuffB[t] - CHAOffset))
7333 
7334  elif MathTrace.get() == 2: # plot difference of CA-V and CB-V
7335  y1 = int(c1 - Yconv1 * (VBuffA[t] - VBuffB[t] - CHAOffset))
7336 
7337  elif MathTrace.get() == 3: # plot difference of CB-V and CA-V
7338  y1 = int(c2 - Yconv2 * (VBuffB[t] - VBuffA[t] - CHBOffset))
7339 
7340  elif MathTrace.get() == 4: # plot product of CA-V and CA-I
7341  Ypower = VBuffA[t] * IBuffA[t] # mAmps * Volts = mWatts
7342  ytemp = YIconv1 * (Ypower - CHAIOffset)
7343  y1 = int(c1 - ytemp)
7344 
7345  elif MathTrace.get() == 5: # plot product of CB-V and CB-I
7346  Ypower = VBuffB[t] * IBuffB[t] # mAmps * Volts = mWatts
7347  ytemp = YIconv2 * (Ypower - CHBIOffset)
7348  y1 = int(c2 - ytemp)
7349 
7350  elif MathTrace.get() == 6: # plot ratio of CA-V and CA-I
7351  Yohms = VBuffA[t] / (IBuffA[t] / 1000.0) # Volts / Amps = ohms
7352  ytemp = YIconv1 * (Yohms- CHAIOffset)
7353  y1 = int(c1 - ytemp)
7354 
7355  elif MathTrace.get() == 7: # plot ratio of CB-V and CB-I
7356  Yohms = VBuffB[t] / (IBuffB[t] / 1000.0) # Volts / Amps = ohms
7357  ytemp = YIconv2 * (Yohms - CHBIOffset)
7358  y1 = int(c2 - ytemp)
7359 
7360  elif MathTrace.get() == 8: # plot difference of CA-I and CB-I
7361  Ydif = (IBuffA[t] - IBuffB[t]) # in mA
7362  ytemp = YIconv1 * (Ydif - CHAIOffset)
7363  y1 = int(c2 - ytemp)
7364 
7365  elif MathTrace.get() == 9: # plot difference of CB-I and CA-I
7366  Ydif = (IBuffB[t] - IBuffA[t]) # in mA
7367  ytemp = YIconv2 * (Ydif - CHBIOffset)
7368  y1 = int(c2 - ytemp)
7369 
7370  elif MathTrace.get() == 10: # plot ratio of CB-V and CA-V
7371  try:
7372  y1 = int(c1 - Yconv2 * ((VBuffB[t] / VBuffA[t]) - CHBOffset)) # voltage gain A to B
7373  except:
7374  y1 = int(c1 - Yconv2 * ((VBuffB[t] / 0.000001) - CHBOffset))
7375  elif MathTrace.get() == 11: # plot ratio of CB-I and CA-I
7376  try:
7377  Y1 = (IBuffB[t] / IBuffA[t]) # current gain A to B
7378  except:
7379  Y1 = (IBuffB[t] / 0.000001)
7380  ytemp = YIconv2 * (Y1 - CHBIOffset)
7381  y1 = int(c2 - ytemp)
7382 
7383  elif MathTrace.get() == 12: # plot from equation string
7384  # MathString = "(VBuffA[t]+ VBuffB[t] - CHAOffset)"
7385  try:
7386  MathResult = eval(MathString)
7387  MathResult = MathResult - CHMOffset
7388  y1 = int(c1 - YconvM * MathResult)
7389  except:
7390  RUNstatus.set(0)
7391  x = GRW + 1
7392 
7393  if (y1 < Ymin):
7394  y1 = Ymin
7395  if (y1 > Ymax):
7396  y1 = Ymax
7397  if (ZOHold.get() == 1):
7398  Tmathline.append(int(x1))
7399  Tmathline.append(int(ypm))
7400  Tmathline.append(int(x1))
7401  Tmathline.append(int(y1))
7402  else:
7403  Tmathline.append(int(x1))
7404  Tmathline.append(int(y1))
7405  ypm = y1
7406  if Show_MathX.get() > 0:
7407  try:
7408  MathResult = eval(MathXString)
7409  MathResult = MathResult - CHMXOffset
7410  y1 = int(c1 - XconvMxy * MathResult)
7411  except:
7412  RUNstatus.set(0)
7413  x = GRW + 1
7414 
7415  if y1 < Ymin: # clip waveform if going off grid
7416  y1 = Ymin
7417  if y1 > Ymax:
7418  y1 = Ymax
7419  if ZOHold.get() == 1: # connet the dots with stair step
7420  TMXline.append(int(x1))
7421  TMXline.append(int(ypmx))
7422  TMXline.append(int(x1))
7423  TMXline.append(int(y1))
7424  else: # connet the dots with single line
7425  TMXline.append(int(x1))
7426  TMXline.append(int(y1))
7427  ypmx = y1
7428  if Show_MathY.get() > 0:
7429  try:
7430  MathResult = eval(MathYString)
7431  MathResult = MathResult - CHMYOffset
7432  y1 = int(c1 - YconvMxy * MathResult)
7433  except:
7434  RUNstatus.set(0)
7435  x = GRW + 1
7436 
7437  if y1 < Ymin: # clip waveform if going off grid
7438  y1 = Ymin
7439  if y1 > Ymax:
7440  y1 = Ymax
7441  if ZOHold.get() == 1: # connet the dots with stair step
7442  TMYline.append(int(x1))
7443  TMYline.append(int(ypmy))
7444  TMYline.append(int(x1))
7445  TMYline.append(int(y1))
7446  else: # connet the dots with single line
7447  TMYline.append(int(x1))
7448  TMYline.append(int(y1))
7449  ypmy = y1
7450  ft = ft + Tstep
7451  if (MouseX - X0L) == x: # > (x - 1) and (MouseX - X0L) < (x + 1):
7452  MouseCAV = ypv1
7453  MouseCAI = ypi1
7454  MouseCBV = ypv2
7455  MouseCBI = ypi2
7456  t = int(ft)
7457  if (t > len(VBuffA)):
7458  t = len(VBuffA)-2
7459  x = GRW
7460  x = x + Xstep
7461 
7462  # Make trigger triangle pointer
7463  Triggerline = [] # Trigger pointer
7464  Triggersymbol = [] # Trigger symbol
7465  if TgInput.get() > 0 or ChopTrig.get() > 0:
7466  if TgInput.get() == 1 or TgInput.get() == 5: # triggering on CA-V
7467  x1 = X0L
7468  ytemp = Yconv1 * (float(TRIGGERlevel)-CHAOffset) #
7469  y1 = int(c1 - ytemp)
7470  elif TgInput.get() == 2: # triggering on CA-I
7471  x1 = X0L+GRW
7472  y1 = int(c1 - YIconv1 * (float(TRIGGERlevel) - CHAIOffset))
7473  elif TgInput.get() == 3: # triggering on CB-V
7474  x1 = X0L
7475  ytemp = Yconv2 * (float(TRIGGERlevel)-CHBOffset) #
7476  y1 = int(c2 - ytemp)
7477  elif TgInput.get() == 4: # triggering on CB-I
7478  x1 = X0L+GRW
7479  y1 = int(c2 - YIconv2 * (float(TRIGGERlevel) - CHBIOffset))
7480  elif ChopTrig.get() == 1: # triggering on Mux A
7481  x1 = X0L
7482  ytemp = YconvMA * (float(TRIGGERlevel)-CHBAOffset) #
7483  y1 = int(c1 - ytemp)
7484  elif ChopTrig.get() == 2: # triggering on Mux B
7485  x1 = X0L
7486  ytemp = YconvMB * (float(TRIGGERlevel)-CHBBOffset) #
7487  y1 = int(c1 - ytemp)
7488  elif ChopTrig.get() == 3: # triggering on Mux A
7489  x1 = X0L
7490  ytemp = YconvMC * (float(TRIGGERlevel)-CHBCOffset) #
7491  y1 = int(c1 - ytemp)
7492  elif ChopTrig.get() == 4: # triggering on Mux A
7493  x1 = X0L
7494  ytemp = YconvMD * (float(TRIGGERlevel)-CHBDOffset) #
7495  y1 = int(c1 - ytemp)
7496  #
7497  if (y1 < Ymin):
7498  y1 = Ymin
7499  if (y1 > Ymax):
7500  y1 = Ymax
7501  Triggerline.append(int(x1-5))
7502  Triggerline.append(int(y1+5))
7503  Triggerline.append(int(x1+5))
7504  Triggerline.append(int(y1))
7505  Triggerline.append(int(x1-5))
7506  Triggerline.append(int(y1-5))
7507  Triggerline.append(int(x1-5))
7508  Triggerline.append(int(y1+5))
7509  x1 = X0L + (GRW/2)
7510  if TgEdge.get() == 0: # draw rising edge symbol
7511  y1 = -3
7512  y2 = -13
7513  else:
7514  y1 = -13
7515  y2 = -3
7516  Triggersymbol.append(int(x1-10))
7517  Triggersymbol.append(int(Ymin+y1))
7518  Triggersymbol.append(int(x1))
7519  Triggersymbol.append(int(Ymin+y1))
7520  Triggersymbol.append(int(x1))
7521  Triggersymbol.append(int(Ymin+y2))
7522  Triggersymbol.append(int(x1+10))
7523  Triggersymbol.append(int(Ymin+y2))
7524 
7525 def MakeXYTrace():
7526  global VBuffA, VBuffB, IBuffA, IBuffB
7527  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
7528  global VUnAvgA, VUnAvgB, IUnAvgA, IUnAvgB, UnAvgSav
7529  global XYlineVA, XYlineVB, XYlineIA, XYlineIB, XYlineM, XYlineMX, XYlineMY
7530  global MathXString, MathYString, MathAxis, MathXAxis, MathYAxis
7531  global HoldOff, HoldOffentry
7532  global X0LXY, Y0TXY, GRWXY, GRHXY
7533  global YminXY, YmaxXY, XminXY, XmaxXY
7534  global SHOWsamples, ZOHold, AWGBMode
7535  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
7536  global TRACES, TRACESread, RUNstatus
7537  global Xsignal, YsignalVA, YsignalVB, YsignalIA, YsignalIB, YsignalM, YsignalMX, YsignalMY
7538  global CHAsbxy, CHBsbxy, CHAOffset, CHBOffset, CHAIsbxy, CHBIsbxy, CHAIOffset, CHBIOffset
7539  global TMpdiv # Array with time / div values in ms
7540  global TMsb # Time per div spin box variable
7541  global TIMEdiv # current spin box value
7542  global SAMPLErate
7543  global SCstart, MathString
7544  global TRIGGERsample, TRACEsize, DX
7545  global TRIGGERlevel, TRIGGERentry, AutoLevel
7546  global InOffA, InGainA, InOffB, InGainB
7547  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
7548  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
7549  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
7550  global CHAVPosEntryxy, CHAIPosEntryxy, CHAVPosEntryxy, CHBIPosEntryxy
7551  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
7552  global HozPoss, HozPossentry
7553 
7554  # Set the TRACEsize variable
7555  if len(VBuffA) < 100:
7556  return
7557  TRACEsize = SHOWsamples # Set the trace length
7558  SCstart = 0
7559  yloVA = yloVB = yloIA = yloIB = yloM = yloMX = yloMY = 0.0
7560  xlo = 0.0
7561  # get the vertical ranges
7562  try:
7563  CH1pdvRange = float(eval(CHAsbxy.get()))
7564  except:
7565  CHAsbxy.delete(0,END)
7566  CHAsbxy.insert(0, CH1pdvRange)
7567  try:
7568  CH2pdvRange = float(eval(CHBsbxy.get()))
7569  except:
7570  CHBsbxy.delete(0,END)
7571  CHBsbxy.insert(0, CH2pdvRange)
7572  try:
7573  CH1IpdvRange = float(eval(CHAIsbxy.get()))
7574  except:
7575  CHAIsbxy.delete(0,END)
7576  CHAIsbxy.insert(0, CH1IpdvRange)
7577  try:
7578  CH2IpdvRange = float(eval(CHBIsbxy.get()))
7579  except:
7580  CHBIsbxy.delete(0,END)
7581  CHBIsbxy.insert(0, CH2IpdvRange)
7582  # get the vertical offsets
7583  try:
7584  CHAOffset = float(eval(CHAVPosEntryxy.get()))
7585  except:
7586  CHAVPosEntryxy.delete(0,END)
7587  CHAVPosEntryxy.insert(0, CHAOffset)
7588  try:
7589  CHAIOffset = float(eval(CHAIPosEntryxy.get()))
7590  except:
7591  CHAIPosEntryxy.delete(0,END)
7592  CHAIPosEntryxy.insert(0, CHAIOffset)
7593  try:
7594  CHBOffset = float(eval(CHBVPosEntryxy.get()))
7595  except:
7596  CHBVPosEntry.delete(0,END)
7597  CHBVPosEntry.insert(0, CHBOffset)
7598  try:
7599  CHBIOffset = float(eval(CHBIPosEntryxy.get()))
7600  except:
7601  CHBIPosEntryxy.delete(0,END)
7602  CHBIPosEntryxy.insert(0, CHBIOffset)
7603  # prevent divide by zero error
7604  if CH1pdvRange < 0.001:
7605  CH1pdvRange = 0.001
7606  if CH2pdvRange < 0.001:
7607  CH2pdvRange = 0.001
7608  if CH1IpdvRange < 0.1:
7609  CH1IpdvRange = 0.1
7610  if CH2IpdvRange < 0.1:
7611  CH2IpdvRange = 0.1
7612  #
7613  Yconv1 = float(GRHXY/10.0) / CH1pdvRange # Vertical Conversion factors from samples to screen points
7614  Yconv2 = float(GRHXY/10.0) / CH2pdvRange
7615  YIconv1 = float(GRHXY/10.0) / CH1IpdvRange
7616  YIconv2 = float(GRHXY/10.0) / CH2IpdvRange
7617  Xconv1 = float(GRWXY/10.0) / CH1pdvRange # Horizontal Conversion factors from samples to screen points
7618  Xconv2 = float(GRWXY/10.0) / CH2pdvRange
7619  XIconv1 = float(GRWXY/10.0) / CH1IpdvRange
7620  XIconv2 = float(GRWXY/10.0) / CH2IpdvRange
7621 
7622  if MathAxis == "V-A":
7623  YconvM = Yconv1
7624  CHMOffset = CHAOffset
7625  elif MathAxis == "V-B":
7626  YconvM = Yconv2
7627  CHMOffset = CHBOffset
7628  elif MathAxis == "I-A":
7629  YconvM = YIconv1
7630  CHMOffset = CHAIOffset
7631  elif MathAxis == "I-B":
7632  YconvM = YIconv2
7633  CHMOffset = CHBIOffset
7634  else:
7635  YconvM = Yconv1
7636  CHMYOffset = CHAOffset
7637  if MathYAxis == "V-A":
7638  YconvMy = Yconv1
7639  CHMYOffset = CHAOffset
7640  elif MathYAxis == "V-B":
7641  YconvMy = Yconv2
7642  CHMYOffset = CHBOffset
7643  elif MathYAxis == "I-A":
7644  YconvMy = YIconv1
7645  CHMYOffset = CHAIOffset
7646  elif MathYAxis == "I-B":
7647  YconvMy = YIconv2
7648  CHMYOffset = CHBIOffset
7649  else:
7650  YconvMy = Yconv1
7651  CHMYOffset = CHAOffset
7652  if MathXAxis == "V-A":
7653  XconvMxy = Xconv1
7654  CHMXOffset = CHAOffset
7655  YconvMx = Yconv1
7656  elif MathXAxis == "V-B":
7657  XconvMxy = Xconv2
7658  CHMXOffset = CHBOffset
7659  YconvMx = Yconv2
7660  elif MathXAxis == "I-A":
7661  XconvMxy = XIconv1
7662  CHMXOffset = CHAIOffset
7663  YconvMx = YIconv1
7664  elif MathXAxis == "I-B":
7665  XconvMxy = XIconv2
7666  CHMXOffset = CHBIOffset
7667  YconvMx = YIconv2
7668  else:
7669  XconvMxy = Xconv1
7670  CHMXOffset = CHAOffset
7671  YconvMx = Yconv1
7672  # draw an X/Y plot
7673  XYlineVA = [] # XY Trace lines
7674  XYlineVB = []
7675  XYlineIA = []
7676  XYlineIB = []
7677  XYlineM = []
7678  XYlineMX = []
7679  XYlineMY = []
7680  t = int(TRIGGERsample) # skip over sampled before hold off time and trigger point
7681  c1 = GRHXY / 2.0 + Y0TXY # fixed correction channel A
7682  c2 = GRWXY / 2.0 + X0LXY # Hor correction factor
7683  while (t < TRACEsize):
7684  # calculate X axis points
7685  if Xsignal.get() == 1: # CVA
7686  xlo = VBuffA[t] - CHAOffset
7687  xlo = int(c2 + Xconv1 * xlo)
7688  elif Xsignal.get() == 3: # CVB
7689  xlo = VBuffB[t] - CHBOffset
7690  xlo = int(c2 + Xconv2 * xlo)
7691  elif Xsignal.get() == 2: # CAI
7692  xlo = (IBuffA[t]) - CHAIOffset
7693  xlo = int(c2 + XIconv1 * xlo)
7694  elif Xsignal.get() == 4: # CBI
7695  xlo = (IBuffB[t]) - CHBIOffset
7696  xlo = int(c2 + XIconv2 * xlo)
7697  elif Xsignal.get() == 5: # Math
7698  if MathTrace.get() == 2: # plot difference of CA-V and CB-V
7699  xlo = VBuffA[t] - VBuffB[t] - CHAOffset
7700  xlo = int(c2 + Xconv1 * xlo)
7701  elif MathTrace.get() == 3: # plot difference of CB-V and CA-V
7702  xlo = VBuffB[t] - VBuffA[t] - CHBOffset
7703  xlo = int(c2 + Xconv2 * xlo)
7704  else:
7705  try:
7706  MathResult = eval(MathXString)
7707  MathResult = MathResult - CHMXOffset
7708  xlo = int(c2 + XconvMxy * MathResult)
7709  except:
7710  RUNstatus.set(0)
7711  if xlo < XminXY: # clip waveform if going off grid
7712  xlo = XminXY
7713  if xlo > XmaxXY:
7714  xlo = XmaxXY
7715  # calculate Y axis points
7716  if YsignalVA.get() == 1: # CAV
7717  yloVA = VBuffA[t] - CHAOffset
7718  yloVA = int(c1 - Yconv1 * yloVA)
7719  if yloVA < YminXY: # clip waveform if going off grid
7720  yloVA = YminXY
7721  if yloVA > YmaxXY:
7722  yloVA = YmaxXY
7723  XYlineVA.append(int(xlo))
7724  XYlineVA.append(int(yloVA))
7725  if YsignalVB.get() == 1: # CBV
7726  yloVB = VBuffB[t] - CHBOffset
7727  yloVB = int(c1 - Yconv2 * yloVB)
7728  if yloVB < YminXY: # clip waveform if going off grid
7729  yloVB = YminXY
7730  if yloVB > YmaxXY:
7731  yloVB = YmaxXY
7732  XYlineVB.append(int(xlo))
7733  XYlineVB.append(int(yloVB))
7734  if YsignalIB.get() == 1: # CBI
7735  yloIB = (IBuffB[t]) - CHBIOffset
7736  yloIB = int(c1 - YIconv2 * yloIB)
7737  if yloIB < YminXY: # clip waveform if going off grid
7738  yloIB = YminXY
7739  if yloIB > YmaxXY:
7740  yloIB = YmaxXY
7741  XYlineIB.append(int(xlo))
7742  XYlineIB.append(int(yloIB))
7743  if YsignalIA.get() == 1: # CAI
7744  yloIA = (IBuffA[t]) - CHAIOffset
7745  yloIA = int(c1 - YIconv1 * yloIA)
7746  if yloIA < YminXY: # clip waveform if going off grid
7747  yloIA = YminXY
7748  if yloIA > YmaxXY:
7749  yloIA = YmaxXY
7750  XYlineIA.append(int(xlo))
7751  XYlineIA.append(int(yloIA))
7752  if YsignalM.get() == 1: # Math
7753  if MathTrace.get() == 2: # plot difference of CA-V and CB-V
7754  yloM = VBuffA[t] - VBuffB[t] - CHAOffset
7755  yloM = int(c1 - Yconv1 * yloM)
7756  elif MathTrace.get() == 3: # plot difference of CB-V and CA-V
7757  yloM = VBuffB[t] - VBuffA[t] - CHBOffset
7758  yloM = int(c1 - Yconv2 * yloM)
7759  else:
7760  try:
7761  MathResult = eval(MathString)
7762  MathResult = MathResult - CHMOffset
7763  yloM = int(c1 - YconvM * MathResult)
7764  except:
7765  RUNstatus.set(0)
7766  if yloM < YminXY: # clip waveform if going off grid
7767  yloM = YminXY
7768  if yloM > YmaxXY:
7769  yloM = YmaxXY
7770  XYlineM.append(int(xlo))
7771  XYlineM.append(int(yloM))
7772  if YsignalMX.get() == 1: # Math-X
7773  try:
7774  MathResult = eval(MathXString)
7775  MathResult = MathResult - CHMXOffset
7776  yloMX = int(c1 - YconvMx * MathResult)
7777  except:
7778  RUNstatus.set(0)
7779  if yloMX < YminXY: # clip waveform if going off grid
7780  yloMX = YminXY
7781  if yloMX > YmaxXY:
7782  yloMX = YmaxXY
7783  XYlineMX.append(int(xlo))
7784  XYlineMX.append(int(yloMX))
7785  if YsignalMY.get() == 1: # Math-Y
7786  try:
7787  MathResult = eval(MathYString)
7788  MathResult = MathResult - CHMYOffset
7789  yloMY = int(c1 - YconvMy * MathResult)
7790  except:
7791  RUNstatus.set(0)
7792  if yloMY < YminXY: # clip waveform if going off grid
7793  yloMY = YminXY
7794  if yloMY > YmaxXY:
7795  yloMY = YmaxXY
7796  XYlineMY.append(int(xlo))
7797  XYlineMY.append(int(yloMY))
7798 
7799  t = int(t + 1)
7800 
7801 def MakeTimeScreen():
7802  global T1Vline, T2Vline, T1Iline, T2Iline, TXYline # active trave lines
7803  global TMXline, TMYline
7804  global T1VRline, T2VRline, T1IRline, T2IRline # reference trace lines
7805  global D0line, D1line, D2line, D3line, D0, D1, D2, D3
7806  global Triggerline, Triggersymbol, Tmathline, TMRline, TXYRline
7807  global VBuffA, VBuffB, IBuffA, IBuffB
7808  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, MuxScreenStatus, ChopMuxMode, ChopTrig
7809  global TMAVline, TMBVline, TMCVline, TMDVline, TMARline, TMBRline, TMCRline, TMDRline
7810  global VmemoryA, VmemoryB, VmemoryA, ImemoryB
7811  global VUnAvgA, VUnAvgB, IUnAvgA, IUnAvgB, UnAvgSav
7812  global X0L # Left top X value
7813  global Y0T # Left top Y value
7814  global GRW # Screenwidth
7815  global GRH # Screenheight
7816  global FontSize, EnableHSsampling, ETSDisp, MinigenScreenStatus
7817  global LabelPlotText, PlotLabelText # plot custom label text flag
7818  global MouseX, MouseY, MouseWidget, MouseCAV, MouseCAI, MouseCBV, MouseCBI
7819  global MouseMuxA, MouseMuxB, MouseMuxC, MouseMuxD
7820  global ShowXCur, ShowYCur, TCursor, VCursor
7821  global SHOWsamples # Number of samples in data record
7822  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, Show_MathX, Show_MathY
7823  global ShowRA_V, ShowRA_I, ShowRB_V, ShowRB_I, ShowMath
7824  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MathUnits, MathXUnits, MathYUnits
7825  global ShowRMA, ShowRMB, ShowRMC, ShowRMD
7826  global Xsignal, Ysignal, MathTrace, MathAxis, MathXAxis, MathYAxis
7827  global RUNstatus, SingleShot, ManualTrigger, session # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
7828  global CHAsb # V range spinbox Index for channel 1
7829  global CHBsb # V range spinbox Index for channel 2
7830  global CHAOffset # Position value for channel 1 V
7831  global CHBOffset # Position value for channel 2 V
7832  global CHAIsb # I range spinbox Index for channel 1
7833  global CHBIsb # I range spinbox Index for channel 2
7834  global CHAIOffset # Postion value for channel 1 I
7835  global CHBIOffset # position value for channel 2 I
7836  global TMpdiv # Array with time / div values in ms
7837  global TMsb # Time per div spin box variable
7838  global TIMEdiv, Mulx, DISsamples # current spin box value
7839  global SAMPLErate, contloop, discontloop, HtMulEntry
7840  global TRIGGERsample, TRIGGERlevel, HoldOff, HoldOffentry, TgInput
7841  global COLORgrid, COLORzeroline, COLORtext, COLORtrigger, COLORtrace7, COLORtraceR7 # The colors
7842  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5, COLORtrace6
7843  global COLORtraceR1, COLORtraceR2, COLORtraceR3, COLORtraceR4, COLORtraceR5, COLORtraceR6
7844  global CANVASwidth, CANVASheight
7845  global TRACErefresh, TRACEmode, TRACEwidth, GridWidth
7846  global ScreenTrefresh, SmoothCurves, Is_Triggered
7847  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2, CHAHW, CHALW, CHADCy, CHAperiod, CHAfreq
7848  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2, CHBHW, CHBLW, CHBDCy, CHBperiod, CHBfreq
7849  global InOffA, InGainA, InOffB, InGainB
7850  global CurOffA, CurOffB, CurGainA, CurGainB
7851  # Analog Mux channel measurement variables
7852  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
7853  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
7854  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
7855  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
7856  global SV1, SI1, SV2, SI2, CHABphase, SVA_B
7857  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1
7858  global MeasDCI1, MeasMinI1, MeasMaxI1, MeasMidI1, MeasPPI1
7859  global MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2, MeasPPV2
7860  global MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2
7861  global MeasRMSV1, MeasRMSI1, MeasRMSV2, MeasRMSI2, MeasPhase, MeasRMSVA_B
7862  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ
7863  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
7864  global AWGAShape, AWGBShape, MeasDiffAB, MeasDiffBA
7865  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
7866  global CHAVPosEntry, CHAIPosEntry, CHAVPosEntry, CHBIPosEntry
7867  global CH1pdvRange, CHAOffset, CH2pdvRange, CHBOffset
7868  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry
7869  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
7870  global DacScreenStatus, DigScreenStatus, CHA_RC_HP, CHB_RC_HP
7871  global D0, D1, D2, D3, D4, D5, D6, D7
7872  global DevID, devx, MarkerNum, MarkerScale, MeasGateLeft, MeasGateRight, MeasGateStatus
7873  global HozPoss, HozPossentry, First_Slow_sweep, Roll_Mode
7874  global VABase, VATop, VBBase, VBTop, UserALabel, UserAString, UserBLabel, UserBString
7875  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2, MeasUserA, MeasUserB
7876  global CHBADelayR1, CHBADelayR2, CHBADelayF, MeasDelay
7877  #
7878  Ymin = Y0T # Minimum position of time grid (top)
7879  Ymax = Y0T + GRH # Maximum position of time grid (bottom)
7880 
7881  # DISsamples = (10.0 * TIMEdiv) # grid width in time
7882  Tstep = (10.0 * TIMEdiv) / GRW # time in mS per pixel
7883  # get the vertical ranges
7884  try:
7885  CH1pdvRange = float(eval(CHAsb.get()))
7886  except:
7887  CHAsb.delete(0,END)
7888  CHAsb.insert(0, CH1pdvRange)
7889  try:
7890  CH2pdvRange = float(eval(CHBsb.get()))
7891  except:
7892  CHBsb.delete(0,END)
7893  CHBsb.insert(0, CH2pdvRange)
7894  try:
7895  CH1IpdvRange = float(eval(CHAIsb.get()))
7896  except:
7897  CHAIsb.delete(0,END)
7898  CHAIsb.insert(0, CH1IpdvRange)
7899  try:
7900  CH2IpdvRange = float(eval(CHBIsb.get()))
7901  except:
7902  CHBIsb.delete(0,END)
7903  CHBIsb.insert(0, CH2IpdvRange)
7904  # get the vertical offsets
7905  try:
7906  CHAOffset = float(eval(CHAVPosEntry.get()))
7907  except:
7908  CHAVPosEntry.delete(0,END)
7909  CHAVPosEntry.insert(0, CHAOffset)
7910  try:
7911  CHAIOffset = float(eval(CHAIPosEntry.get()))
7912  except:
7913  CHAIPosEntry.delete(0,END)
7914  CHAIPosEntry.insert(0, CHAIOffset)
7915  try:
7916  CHBOffset = float(eval(CHBVPosEntry.get()))
7917  except:
7918  CHBVPosEntry.delete(0,END)
7919  CHBVPosEntry.insert(0, CHBOffset)
7920  try:
7921  CHBIOffset = float(eval(CHBIPosEntry.get()))
7922  except:
7923  CHBIPosEntry.delete(0,END)
7924  CHBIPosEntry.insert(0, CHBIOffset)
7925  try:
7926  HoldOff = float(eval(HoldOffentry.get()))
7927  if HoldOff < 0:
7928  HoldOff = 0
7929  except:
7930  HoldOffentry.delete(0,END)
7931  HoldOffentry.insert(0, HoldOff)
7932  if ETSDisp.get() > 0 or MinigenScreenStatus.get() > 0:
7933  try:
7934  Mulx = float(eval(HtMulEntry.get()))
7935  if Mulx < 1:
7936  Mulx = 1
7937  except:
7938  Mulx = 1
7939  if EnableHSsampling > 0:
7940  HtMulEntry.delete(0,END)
7941  HtMulEntry.insert(0, 1)
7942  else:
7943  Mulx = 1
7944  # slide trace left right by HozPoss
7945  try:
7946  HozPoss = float(eval(HozPossentry.get()))
7947  except:
7948  HozPossentry.delete(0,END)
7949  HozPossentry.insert(0, HozPoss)
7950  if MuxScreenStatus.get() == 1: # if using analog Mux set up axis controls
7951  try:
7952  CHMApdvRange = float(eval(CHB_Asb.get()))
7953  except:
7954  CHB_Asb.delete(0,END)
7955  CHB_Asb.insert(0, CHMApdvRange)
7956  try:
7957  CHMBpdvRange = float(eval(CHB_Bsb.get()))
7958  except:
7959  CHB_Bsb.delete(0,END)
7960  CHB_Bsb.insert(0, CHMBpdvRange)
7961  try:
7962  CHMCpdvRange = float(eval(CHB_Csb.get()))
7963  except:
7964  CHB_Csb.delete(0,END)
7965  CHB_Csb.insert(0, CHMCpdvRange)
7966  try:
7967  CHMDpdvRange = float(eval(CHB_Dsb.get()))
7968  except:
7969  CHB_Dsb.delete(0,END)
7970  CHB_Dsb.insert(0, CHMDpdvRange)
7971  if CHMApdvRange < 0.001:
7972  CHMApdvRange = 0.001
7973  if CHMBpdvRange < 0.001:
7974  CHMBpdvRange = 0.001
7975  if CHMCpdvRange < 0.001:
7976  CHMCpdvRange = 0.001
7977  if CHMDpdvRange < 0.001:
7978  CHMDpdvRange = 0.001
7979  try:
7980  CHBAOffset = float(eval(CHB_APosEntry.get()))
7981  except:
7982  CHB_APosEntry.delete(0,END)
7983  CHB_APosEntry.insert(0, CHBAOffset)
7984  try:
7985  CHBBOffset = float(eval(CHB_BPosEntry.get()))
7986  except:
7987  CHB_BPosEntry.delete(0,END)
7988  CHB_BPosEntry.insert(0, CHBBOffset)
7989  try:
7990  CHBCOffset = float(eval(CHB_CPosEntry.get()))
7991  except:
7992  CHB_CPosEntry.delete(0,END)
7993  CHB_CPosEntry.insert(0, CHBCOffset)
7994  try:
7995  CHBDOffset = float(eval(CHB_DPosEntry.get()))
7996  except:
7997  CHB_DPosEntry.delete(0,END)
7998  CHB_DPosEntry.insert(0, CHBDOffset)
7999  # prevent divide by zero error
8000  if CH1pdvRange < 0.001:
8001  CH1pdvRange = 0.001
8002  if CH2pdvRange < 0.001:
8003  CH2pdvRange = 0.001
8004  if CH1IpdvRange < 0.1:
8005  CH1IpdvRange = 0.1
8006  if CH2IpdvRange < 0.1:
8007  CH2IpdvRange = 0.1
8008  vt = HoldOff + HozPoss # invert sign and scale to mSec
8009  if ScreenTrefresh.get() == 0:
8010  # Delete all items on the screen
8011  ca.delete(ALL) # remove all items
8012  MarkerNum = 0
8013  # Draw horizontal grid lines
8014  i = 0
8015  x1 = X0L
8016  x2 = X0L + GRW
8017  mg_siz = GRW/10.0
8018  mg_inc = mg_siz/5.0
8019  MathFlag1 = (MathAxis == "V-A" and MathTrace.get() == 12) or (MathXAxis == "V-A" and Show_MathX.get() == 1) or (MathYAxis == "V-A" and Show_MathY.get() == 1)
8020  MathFlag2 = (MathAxis == "V-B" and MathTrace.get() == 12) or (MathXAxis == "V-B" and Show_MathX.get() == 1) or (MathYAxis == "V-B" and Show_MathY.get() == 1)
8021  MathFlag3 = (MathAxis == "I-A" and MathTrace.get() == 12) or (MathXAxis == "I-A" and Show_MathX.get() == 1) or (MathYAxis == "I-A" and Show_MathY.get() == 1)
8022  MathFlag4 = (MathAxis == "I-B" and MathTrace.get() == 12) or (MathXAxis == "I-B" and Show_MathX.get() == 1) or (MathYAxis == "I-B" and Show_MathY.get() == 1)
8023  # vertical scale text labels
8024  RightOffset = FontSize * 3
8025  LeftOffset = int(FontSize/2)
8026  if (ShowC1_V.get() == 1 or MathTrace.get() == 1 or MathTrace.get() == 2 or MathFlag1):
8027  ca.create_text(x1-LeftOffset, 12, text="CA-V", fill=COLORtrace1, anchor="e", font=("arial", FontSize-1 ))
8028  if (ShowC1_I.get() == 1 or MathTrace.get() == 4 or MathTrace.get() == 6 or MathTrace.get() == 8 or MathFlag3):
8029  ca.create_text(x2+LeftOffset, 12, text="CA-I", fill=COLORtrace3, anchor="w", font=("arial", FontSize-1 ))
8030  if (ShowC2_V.get() == 1 or MathTrace.get() == 3 or MathTrace.get() == 10 or MathFlag2):
8031  ca.create_text(x1-RightOffset+2, 12, text="CB-V", fill=COLORtrace2, anchor="e", font=("arial", FontSize-1 )) #26
8032  if (ShowC2_I.get() == 1 or MathTrace.get() == 5 or MathTrace.get() == 7 or MathTrace.get() == 9 or MathTrace.get() == 11 or MathFlag4):
8033  ca.create_text(x2+RightOffset+4, 12, text="CB-I", fill=COLORtrace4, anchor="w", font=("arial", FontSize-1 )) #28
8034  #
8035  while (i < 11):
8036  y = Y0T + i * GRH/10.0
8037  Dline = [x1,y,x2,y]
8038  if i == 5:
8039  ca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue line at center of grid
8040  k = 0
8041  while (k < 10):
8042  l = 1
8043  while (l < 5):
8044  Dline = [x1+k*mg_siz+l*mg_inc,y-5,x1+k*mg_siz+l*mg_inc,y+5]
8045  ca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
8046  l = l + 1
8047  k = k + 1
8048  else:
8049  ca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
8050 
8051  if (ShowC1_V.get() == 1 or MathTrace.get() == 1 or MathTrace.get() == 2 or MathFlag1):
8052  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8053  # Vaxis_label = ' {0:.2f} '.format(Vaxis_value)
8054  Vaxis_label = str(round(Vaxis_value,3 ))
8055  ca.create_text(x1-LeftOffset, y, text=Vaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
8056 
8057  if (ShowC1_I.get() == 1 or MathTrace.get() == 4 or MathTrace.get() == 6 or MathTrace.get() == 8 or MathFlag3):
8058  Iaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
8059  Iaxis_label = str(round(Iaxis_value, 3))
8060  ca.create_text(x2+LeftOffset, y, text=Iaxis_label, fill=COLORtrace3, anchor="w", font=("arial", FontSize ))
8061 
8062  if (ShowC2_V.get() == 1 or MathTrace.get() == 3 or MathTrace.get() == 10 or MathFlag2):
8063  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
8064  Vaxis_label = str(round(Vaxis_value, 3))
8065  ca.create_text(x1-RightOffset+2, y, text=Vaxis_label, fill=COLORtrace2, anchor="e", font=("arial", FontSize )) # 26
8066 
8067  if (ShowC2_I.get() == 1 or MathTrace.get() == 5 or MathTrace.get() == 7 or MathTrace.get() == 9 or MathTrace.get() == 11 or MathFlag4):
8068  Iaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
8069  Iaxis_label = str(round(Iaxis_value, 3))
8070  ca.create_text(x2+RightOffset+4, y, text=Iaxis_label, fill=COLORtrace4, anchor="w", font=("arial", FontSize )) # 28
8071  if MuxScreenStatus.get() == 1:
8072  if Show_CBA.get() == 1:
8073  Vaxis_value = (((5-i) * CHMApdvRange ) + CHBAOffset)
8074  Vaxis_label = str(round(Vaxis_value, 3))
8075  ca.create_text(x1-RightOffset+2, y, text=Vaxis_label, fill=COLORtrace2, anchor="e", font=("arial", FontSize )) # 26
8076  if Show_CBB.get() == 1:
8077  Iaxis_value = 1.0 * (((5-i) * CHMBpdvRange ) + CHBBOffset)
8078  Iaxis_label = str(round(Iaxis_value, 3))
8079  ca.create_text(x2+LeftOffset, y, text=Iaxis_label, fill=COLORtrace6, anchor="w", font=("arial", FontSize ))
8080  if Show_CBC.get() == 1:
8081  Iaxis_value = 1.0 * (((5-i) * CHMCpdvRange ) + CHBCOffset)
8082  Iaxis_label = str(round(Iaxis_value, 3))
8083  ca.create_text(x2+RightOffset-3, y, text=Iaxis_label, fill=COLORtrace7, anchor="w", font=("arial", FontSize )) # 21
8084  if Show_CBD.get() == 1:
8085  Iaxis_value = 1.0 * (((5-i) * CHMDpdvRange ) + CHBDOffset)
8086  Iaxis_label = str(round(Iaxis_value, 3))
8087  ca.create_text(x2+RightOffset+10, y, text=Iaxis_label, fill=COLORtrace4, anchor="w", font=("arial", FontSize )) # 38
8088  i = i + 1
8089  # Draw vertical grid lines
8090  i = 0
8091  y1 = Y0T
8092  y2 = Y0T + GRH
8093  mg_siz = GRH/10.0
8094  mg_inc = mg_siz/5.0
8095  vx = TIMEdiv/Mulx
8096  vt = HoldOff/Mulx # invert sign and scale to mSec
8097  # vx = TIMEdiv
8098  while (i < 11):
8099  x = X0L + i * GRW/10.0
8100  Dline = [x,y1,x,y2]
8101  if (i == 5):
8102  ca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue vertical line at center of grid
8103  k = 0
8104  while (k < 10):
8105  l = 1
8106  while (l < 5):
8107  Dline = [x-5,y1+k*mg_siz+l*mg_inc,x+5,y1+k*mg_siz+l*mg_inc]
8108  ca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
8109  l = l + 1
8110  k = k + 1
8111  #
8112  if Roll_Mode.get() == 0: # should be same as First_Slow_sweep == 0
8113  if vx >= 1000:
8114  axis_value = ((i * vx)+ vt) / 1000.0
8115  axis_label = ' {0:.1f} '.format(axis_value) + " S"
8116  if vx < 1000 and vx >= 1:
8117  axis_value = (i * vx) + vt
8118  axis_label = ' {0:.1f} '.format(axis_value) + " mS"
8119  if vx < 1:
8120  axis_value = ((i * vx) + vt) * 1000.0
8121  axis_label = ' {0:.1f} '.format(axis_value) + " uS"
8122  ca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
8123  else:
8124  ca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
8125  if Roll_Mode.get() == 0: # should be same as First_Slow_sweep == 0
8126  if vx >= 1000:
8127  axis_value = ((i * vx)+ vt) / 1000.0
8128  axis_label = ' {0:.1f} '.format(axis_value) + " S"
8129  if vx < 1000 and vx >= 1:
8130  axis_value = (i * vx) + vt
8131  axis_label = ' {0:.1f} '.format(axis_value) + " mS"
8132  if vx < 1:
8133  axis_value = ((i * vx) + vt) * 1000.0
8134  axis_label = ' {0:.1f} '.format(axis_value) + " uS"
8135  ca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
8136 
8137  i = i + 1
8138  # Write the trigger line if available
8139  if Roll_Mode.get() == 0: # Don't show trigger indicator when in Roll Mode
8140  if len(Triggerline) > 2: # Avoid writing lines with 1 coordinate
8141  ca.create_polygon(Triggerline, outline=COLORtrigger, fill=COLORtrigger, width=1)
8142  ca.create_line(Triggersymbol, fill=COLORtrigger, width=GridWidth.get())
8143  if TgInput.get() == 1:
8144  TgLabel = "CA-V"
8145  if TgInput.get() == 2:
8146  TgLabel = "CA-I"
8147  if TgInput.get() == 3:
8148  TgLabel = "CB-V"
8149  if TgInput.get() == 4:
8150  TgLabel = "CB-I"
8151  if TgInput.get() == 5:
8152  TgLabel = "VA or VB"
8153  if TgInput.get() == 6:
8154  TgLabel = "Alternate"
8155  if ChopTrig.get() == 1:
8156  TgLabel = "Mux A"
8157  if ChopTrig.get() == 2:
8158  TgLabel = "Mux B"
8159  if ChopTrig.get() == 3:
8160  TgLabel = "Mux C"
8161  if ChopTrig.get() == 4:
8162  TgLabel = "Mux D"
8163  if Is_Triggered == 1:
8164  TgLabel = TgLabel + " Triggered"
8165  else:
8166  TgLabel = TgLabel + " Not Triggered"
8167  if SingleShot.get() > 0:
8168  TgLabel = TgLabel + " Armed"
8169  x = X0L + (GRW/2) + 12
8170  ca.create_text(x, Ymin-FontSize, text=TgLabel, fill=COLORtrigger, anchor="w", font=("arial", FontSize ))
8171  # Draw T - V Cursor lines if required
8172  if MarkerScale.get() == 0:
8173  Yconv1 = float(GRH/10.0) / CH1pdvRange
8174  Yoffset1 = CHAOffset
8175  COLORmarker = COLORtrace1
8176  Units = " V"
8177  if MarkerScale.get() == 1:
8178  MouseY = MouseCAV
8179  Yconv1 = float(GRH/10.0) / CH1pdvRange
8180  Yoffset1 = CHAOffset
8181  COLORmarker = COLORtrace1
8182  Units = " V"
8183  if MarkerScale.get() == 2:
8184  MouseY = MouseCBV
8185  Yconv1 = float(GRH/10.0) / CH2pdvRange
8186  Yoffset1 = CHBOffset
8187  COLORmarker = COLORtrace2
8188  Units = " V"
8189  if MarkerScale.get() == 3:
8190  MouseY = MouseCAI
8191  Yconv1 = float(GRH/10.0) / CH1IpdvRange
8192  Yoffset1 = CHAIOffset
8193  COLORmarker = COLORtrace3
8194  Units = " mA"
8195  if MarkerScale.get() == 4:
8196  MouseY = MouseCBI
8197  Yconv1 = float(GRH/10.0) / CH2IpdvRange
8198  Yoffset1 = CHBIOffset
8199  COLORmarker = COLORtrace4
8200  Units = " mA"
8201  # Analog Mux settings
8202  if MarkerScale.get() == 5:
8203  MouseY = MouseMuxA
8204  Yconv1 = float(GRH/10.0) / CHMApdvRange
8205  Yoffset1 = CHBAOffset
8206  COLORmarker = COLORtrace2
8207  Units = " V"
8208  if MarkerScale.get() == 6:
8209  MouseY = MouseMuxB
8210  Yconv1 = float(GRH/10.0) / CHMBpdvRange
8211  Yoffset1 = CHBBOffset
8212  COLORmarker = COLORtrace6
8213  Units = " V"
8214  if MarkerScale.get() == 7:
8215  MouseY = MouseMuxC
8216  Yconv1 = float(GRH/10.0) / CHMCpdvRange
8217  Yoffset1 = CHBCOffset
8218  COLORmarker = COLORtrace7
8219  Units = " V"
8220  if MarkerScale.get() == 8:
8221  MouseY = MouseMuxD
8222  Yconv1 = float(GRH/10.0) / CHMDpdvRange
8223  Yoffset1 = CHBDOffset
8224  COLORmarker = COLORtrace4
8225  Units = " V"
8226 #
8227  if ShowTCur.get() > 0:
8228  Dline = [TCursor, Y0T, TCursor, Y0T+GRH]
8229  ca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
8230  Tpoint = ((TCursor-X0L) * Tstep) + vt
8231  Tpoint = Tpoint/Mulx
8232  if Tpoint >= 1000:
8233  axis_value = Tpoint / 1000.0
8234  V_label = ' {0:.2f} '.format(axis_value) + " S"
8235  if Tpoint < 1000 and Tpoint >= 1:
8236  axis_value = Tpoint
8237  V_label = ' {0:.2f} '.format(axis_value) + " mS"
8238  if Tpoint < 1:
8239  axis_value = Tpoint * 1000.0
8240  V_label = ' {0:.2f} '.format(axis_value) + " uS"
8241  if Roll_Mode.get() == 0: # should be same as First_Slow_sweep == 0
8242  ca.create_text(TCursor, Y0T+GRH+6, text=V_label, fill=COLORtext, anchor="n", font=("arial", FontSize ))
8243  if ShowVCur.get() > 0:
8244  Dline = [X0L, VCursor, X0L+GRW, VCursor]
8245  ca.create_line(Dline, dash=(4,3), fill=COLORmarker, width=GridWidth.get())
8246  c1 = GRH / 2 + Y0T # fixed Y correction
8247  yvolts = ((VCursor-c1)/Yconv1) - Yoffset1
8248  V1String = ' {0:.3f} '.format(-yvolts)
8249  V_label = V1String + Units
8250  ca.create_text(X0L+GRW+2, VCursor, text=V_label, fill=COLORmarker, anchor="w", font=("arial", FontSize ))
8251  if ShowTCur.get() == 0 and ShowVCur.get() == 0 and MouseWidget == ca:
8252  if MouseX > X0L and MouseX < X0L+GRW and MouseY > Y0T and MouseY < Y0T+GRH:
8253  Dline = [MouseX, Y0T, MouseX, Y0T+GRH]
8254  ca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
8255  ca.create_oval(MouseX-GridWidth.get(), MouseY-GridWidth.get(), MouseX+GridWidth.get(), MouseY+GridWidth.get(), outline=COLORtrigger, fill=COLORtrigger, width=GridWidth.get())
8256  Tpoint = ((MouseX-X0L) * Tstep) + vt
8257  Tpoint = Tpoint/Mulx
8258  if Tpoint >= 1000:
8259  axis_value = Tpoint / 1000.0
8260  V_label = ' {0:.2f} '.format(axis_value) + " S"
8261  if Tpoint < 1000 and Tpoint >= 1:
8262  axis_value = Tpoint
8263  V_label = ' {0:.2f} '.format(axis_value) + " mS"
8264  if Tpoint < 1:
8265  axis_value = Tpoint * 1000.0
8266  V_label = ' {0:.2f} '.format(axis_value) + " uS"
8267  if Roll_Mode.get() == 0: # should be same as First_Slow_sweep == 0
8268  ca.create_text(MouseX, Y0T+GRH+6, text=V_label, fill=COLORtext, anchor="n", font=("arial", FontSize ))
8269  Dline = [X0L, MouseY, X0L+GRW, MouseY]
8270  ca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
8271  c1 = GRH / 2 + Y0T # fixed Y correction
8272  yvolts = ((MouseY-c1)/Yconv1) - Yoffset1
8273  V1String = ' {0:.3f} '.format(-yvolts)
8274  V_label = V1String + Units
8275  ca.create_text(X0L+GRW+2, MouseY, text=V_label, fill=COLORmarker, anchor="w", font=("arial", FontSize ))
8276 #
8277  if MeasGateStatus.get() == 1:
8278  LeftGate = X0L + MeasGateLeft / Tstep
8279  RightGate = X0L + MeasGateRight / Tstep
8280  ca.create_line(LeftGate, Y0T, LeftGate, Y0T+GRH, dash=(5,3), width=GridWidth.get(), fill=COLORtrace5)
8281  ca.create_line(RightGate, Y0T, RightGate, Y0T+GRH, dash=(5,3), width=GridWidth.get(), fill=COLORtrace7)
8282  #
8283  # TString = ' {0:.2f} '.format(Tpoint)
8284  if Roll_Mode.get() == 0: # should be same as First_Slow_sweep == 0
8285  DT = (MeasGateRight-MeasGateLeft)/Mulx
8286  if DT == 0.0:
8287  DT = 1.0
8288  if DT >= 1000:
8289  axis_value = DT / 1000.0
8290  DeltaT = ' {0:.2f} '.format(axis_value) + " S "
8291  if DT < 1000 and DT >= 1:
8292  axis_value = DT
8293  DeltaT = ' {0:.2f} '.format(axis_value) + " mS "
8294  if DT < 1:
8295  axis_value = DT * 1000.0
8296  DeltaT = ' {0:.2f} '.format(axis_value) + " uS "
8297  # DeltaT = ' {0:.3f} '.format(Tpoint-PrevT)
8298  DFreq = ' {0:.3f} '.format(1.0/DT)
8299  V_label = " Delta T" + DeltaT
8300  #V_label = V_label + Units
8301  V_label = V_label + ", Freq " + DFreq + " KHz"
8302  # place in upper left unless specified otherwise
8303  TxScale = FontSize + 2
8304  x = X0L + 5
8305  y = Y0T + 7
8306  Justify = 'w'
8307  if MarkerLoc == 'UR' or MarkerLoc == 'ur':
8308  x = X0L + GRW - 5
8309  y = Y0T + 7
8310  Justify = 'e'
8311  if MarkerLoc == 'LL' or MarkerLoc == 'll':
8312  x = X0L + 5
8313  y = Y0T + GRH + 7 - (MarkerNum*TxScale)
8314  Justify = 'w'
8315  if MarkerLoc == 'LR' or MarkerLoc == 'lr':
8316  x = X0L + GRW - 5
8317  y = Y0T + GRH + 7
8318  Justify = 'e'
8319  ca.create_text(x, y, text=V_label, fill=COLORtrace5, anchor=Justify, font=("arial", FontSize ))
8320  #
8321 #
8322  SmoothBool = SmoothCurves.get()
8323  # Write the traces if available
8324  if len(T1Vline) > 4: # Avoid writing lines with 1 coordinate
8325  ca.create_line(T1Vline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get()) # Write the voltage trace 1
8326  if len(T1Iline) > 4: # Avoid writing lines with 1 coordinate
8327  ca.create_line(T1Iline, fill=COLORtrace3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get()) # Write the current trace 1
8328  if len(T2Vline) > 4: # Write the trace 2 if active
8329  ca.create_line(T2Vline, fill=COLORtrace2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8330  if len(T2Iline) > 4:
8331  ca.create_line(T2Iline, fill=COLORtrace4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8332  if len(Tmathline) > 4 and MathTrace.get() > 0: # Write Math tace if active
8333  ca.create_line(Tmathline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8334  if len(TMXline) > 4 : # Write X Math tace if active
8335  ca.create_line(TMXline, fill=COLORtrace6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8336  if len(TMYline) > 4 : # Write Y Math tace if active
8337  ca.create_line(TMYline, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8338  if MuxScreenStatus.get() == 1:
8339  if len(TMAVline) > 4: # Avoid writing lines with 1 coordinate
8340  ca.create_line(TMAVline, fill=COLORtrace2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8341  if len(TMBVline) > 4: # Avoid writing lines with 1 coordinate
8342  ca.create_line(TMBVline, fill=COLORtrace6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8343  if len(TMCVline) > 4: # Avoid writing lines with 1 coordinate
8344  ca.create_line(TMCVline, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8345  if len(TMDVline) > 4: # Avoid writing lines with 1 coordinate
8346  ca.create_line(TMDVline, fill=COLORtrace4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8347  if ShowRMA.get() == 1 and len(TMARline) > 4:
8348  ca.create_line(TMARline, fill=COLORtraceR2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8349  if ShowRMB.get() == 1 and len(TMBRline) > 4:
8350  ca.create_line(TMBRline, fill=COLORtraceR6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8351  if ShowRMC.get() == 1 and len(TMCRline) > 4:
8352  ca.create_line(TMCRline, fill=COLORtraceR7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8353  if ShowRMD.get() == 1 and len(TMDRline) > 4:
8354  ca.create_line(TMDRline, fill=COLORtraceR4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8355  if ShowRA_V.get() == 1 and len(T1VRline) > 4:
8356  ca.create_line(T1VRline, fill=COLORtraceR1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8357  if ShowRA_I.get() == 1 and len(T1IRline) > 4:
8358  ca.create_line(T1IRline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8359  if ShowRB_V.get() == 1 and len(T2VRline) > 4:
8360  ca.create_line(T2VRline, fill=COLORtraceR2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8361  if ShowRB_I.get() == 1 and len(T2IRline) > 4:
8362  ca.create_line(T2IRline, fill=COLORtraceR4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8363  if ShowMath.get() == 1 and len(TMRline) > 4:
8364  ca.create_line(TMRline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8365  if First_Slow_sweep == 1:
8366  # print(len(D0line),len(D1line), len(D2line), len(D3line))
8367  if D0.get() == 0:
8368  ca.create_line(D0line, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8369  if D1.get() == 0:
8370  ca.create_line(D1line, fill=COLORtrace6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8371  if D2.get() == 0:
8372  ca.create_line(D2line, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8373  if D3.get() == 0:
8374  ca.create_line(D3line, fill=COLORzeroline, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
8375  # General information on top of the grid
8376  # Sweep information
8377  if session.continuous:
8378  sttxt = "Running Continuous"
8379  else:
8380  sttxt = "Running Discontinuous"
8381  if TRACEmodeTime.get() == 1:
8382  sttxt = sttxt + " Averaging"
8383  if ManualTrigger.get() == 1:
8384  sttxt = "Manual Trigger"
8385  if (RUNstatus.get() == 0) or (RUNstatus.get() == 3):
8386  sttxt = "Stopped"
8387  if ScreenTrefresh.get() == 1:
8388  sttxt = sttxt + " Persistance ON"
8389  # Delete text at bottom of screen
8390  de = ca.find_enclosed( X0L-1, Y0T+GRH+12, CANVASwidth, Y0T+GRH+100)
8391  for n in de:
8392  ca.delete(n)
8393  # Delete text at top of screen
8394  de = ca.find_enclosed( X0L-1, -1, CANVASwidth, 20)
8395  for n in de:
8396  ca.delete(n)
8397  if Roll_Mode.get() == 0:
8398  if LabelPlotText.get() > 0:
8399  txt = PlotLabelText + " Sample rate: " + str(SAMPLErate) + " " + sttxt
8400  else:
8401  txt = "Device ID " + DevID[17:31] + " Sample rate: " + str(SAMPLErate) + " " + sttxt
8402  else:
8403  if LabelPlotText.get() > 0:
8404  txt = PlotLabelText + " Rolling Sweep " + sttxt
8405  else:
8406  txt = "Device ID " + DevID[17:31] + " Rolling Sweep " + sttxt
8407  x = X0L+2
8408  y = 12
8409  ca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
8410  # digital I/O indicators
8411  x2 = X0L + GRW
8412  BoxColor = "#808080" # gray
8413  if DacScreenStatus.get() == 0 and (DigScreenStatus.get() == 1 or MuxScreenStatus.get() == 1):
8414  if D0.get() == 0 and D4.get() == 0:
8415  Dval = devx.ctrl_transfer( 0xc0, 0x91, 4, 0, 0, 1, 100)
8416  if Dval[0] == 1:
8417  BoxColor = "#00ff00" # 100% green
8418  elif Dval[0] == 0:
8419  BoxColor = "#ff0000" # 100% red
8420  ca.create_rectangle(x2-12, 6, x2, 18, fill=BoxColor)
8421  else:
8422  ca.create_rectangle(x2-12, 6, x2, 18, fill="yellow")
8423  if D1.get() == 0 and D5.get() == 0:
8424  Dval = devx.ctrl_transfer( 0xc0, 0x91, 5, 0, 0, 1, 100)
8425  if Dval[0] == 1:
8426  BoxColor = "#00ff00" # 100% green
8427  elif Dval[0] == 0:
8428  BoxColor = "#ff0000" # 100% red
8429  ca.create_rectangle(x2-26, 6, x2-14, 18, fill=BoxColor)
8430  else:
8431  ca.create_rectangle(x2-26, 6, x2-14, 18, fill="yellow")
8432  if D2.get() == 0 and D6.get() == 0:
8433  Dval = devx.ctrl_transfer( 0xc0, 0x91, 6, 0, 0, 1, 100)
8434  if Dval[0] == 1:
8435  BoxColor = "#00ff00" # 100% green
8436  elif Dval[0] == 0:
8437  BoxColor = "#ff0000" # 100% red
8438  ca.create_rectangle(x2-40, 6, x2-28, 18, fill=BoxColor)
8439  else:
8440  ca.create_rectangle(x2-40, 6, x2-28, 18, fill="yellow")
8441  if D3.get() == 0 and D7.get() == 0:
8442  Dval = devx.ctrl_transfer( 0xc0, 0x91, 7, 0, 0, 1, 100)
8443  if Dval[0] == 1:
8444  BoxColor = "#00ff00" # 100% green
8445  elif Dval[0] == 0:
8446  BoxColor = "#ff0000" # 100% red
8447  ca.create_rectangle(x2-54, 6, x2-42, 18, fill=BoxColor)
8448  else:
8449  ca.create_rectangle(x2-54, 6, x2-42, 18, fill="yellow")
8450  ca.create_text(x2-56, 12, text="Digital Inputs", anchor=E, fill=COLORtext, font=("arial", FontSize ))
8451  # Time sweep information and view at information
8452  vx = TIMEdiv/Mulx
8453  if vx >= 1000:
8454  txt = ' {0:.2f} '.format(vx / 1000.0) + " S/div"
8455  if vx < 1000 and vx >= 1:
8456  txt = ' {0:.2f} '.format(vx) + " mS/div"
8457  if vx < 1:
8458  txt = ' {0:.2f} '.format(vx * 1000.0) + " uS/div"
8459 
8460  txt = txt + " "
8461  #
8462  txt = txt + "View at "
8463  if abs(vt) >= 1000:
8464  txt = txt + str(int(vt / 1000.0)) + " S "
8465  if abs(vt) < 1000 and abs(vt) >= 1:
8466  txt = txt + str(int(vt)) + " mS "
8467  if abs(vt) < 1:
8468  txt = txt + str(int(vt * 1000.0)) + " uS "
8469  # print period and frequency of displayed channels
8470  if ShowC1_V.get() == 1 or ShowC2_V.get() == 1:
8471  if ETSDisp.get() > 0:
8472  FindRisingEdge(VBuffA[:int(DISsamples)],VBuffB[:int(DISsamples)])
8473  else:
8474  if MeasGateStatus.get() == 1:
8475  if (MeasGateRight-MeasGateLeft) > 0:
8476  hldn = int(MeasGateLeft * SAMPLErate/1000) + TRIGGERsample
8477  Endsample = int(MeasGateRight * SAMPLErate/1000) + TRIGGERsample
8478  if Endsample <= hldn:
8479  Endsample = hldn + 2
8480  FindRisingEdge(VBuffA[hldn:Endsample],VBuffB[hldn:Endsample])
8481  else:
8482  FindRisingEdge(VBuffA,VBuffB)
8483  if ShowC1_V.get() == 1:
8484  if MeasAHW.get() == 1:
8485  txt = txt + " CA Hi Width = " + ' {0:.3f} '.format(CHAHW/Mulx) + " mS "
8486  if MeasALW.get() == 1:
8487  txt = txt + " CA Lo Width = " + ' {0:.3f} '.format(CHALW/Mulx) + " mS "
8488  if MeasADCy.get() == 1:
8489  txt = txt + " CA DutyCycle = " + ' {0:.1f} '.format(CHADCy) + " % "
8490  if MeasAPER.get() == 1:
8491  txt = txt + " CA Period = " + ' {0:.3f} '.format(CHAperiod/Mulx) + " mS "
8492  if MeasAFREQ.get() == 1:
8493  txt = txt + " CA Freq = "
8494  ChaF = CHAfreq*Mulx
8495  if ChaF < 1000:
8496  V1String = ' {0:.1f} '.format(ChaF)
8497  txt = txt + str(V1String) + " Hz "
8498  if ChaF > 1000 and ChaF < 1000000:
8499  V1String = ' {0:.1f} '.format(ChaF/1000)
8500  txt = txt + str(V1String) + " KHz "
8501  if ChaF > 1000000:
8502  V1String = ' {0:.1f} '.format(ChaF/1000000)
8503  txt = txt + str(V1String) + " MHz "
8504  #txt = txt + " CA Freq = " + ' {0:.1f} '.format(CHAfreq) + " Hz "
8505  if ShowC2_V.get() == 1:
8506  if MeasBHW.get() == 1:
8507  txt = txt + " CB Hi Width = " + ' {0:.3f} '.format(CHBHW/Mulx) + " mS "
8508  if MeasBLW.get() == 1:
8509  txt = txt + " CB Lo Width = " + ' {0:.3f} '.format(CHBLW/Mulx) + " mS "
8510  if MeasBDCy.get() == 1:
8511  txt = txt + " CB DutyCycle = " + ' {0:.1f} '.format(CHBDCy) + " % "
8512  if MeasBPER.get() == 1:
8513  txt = txt + " CB Period = " + ' {0:.3f} '.format(CHBperiod/Mulx) + " mS "
8514  if MeasBFREQ.get() == 1:
8515  txt = txt + " CB Freq = "
8516  ChaF = CHBfreq*Mulx
8517  if ChaF < 1000:
8518  V1String = ' {0:.1f} '.format(ChaF)
8519  txt = txt + str(V1String) + " Hz "
8520  if ChaF > 1000 and ChaF < 1000000:
8521  V1String = ' {0:.1f} '.format(ChaF/1000)
8522  txt = txt + str(V1String) + " KHz "
8523  if ChaF > 1000000:
8524  V1String = ' {0:.1f} '.format(ChaF/1000000)
8525  txt = txt + str(V1String) + " MHz "
8526  #txt = txt + " CB Freq = " + ' {0:.1f} '.format(CHBfreq) + " Hz "
8527  if MuxScreenStatus.get() == 0:
8528  if MeasPhase.get() == 1:
8529  txt = txt + " CA-B Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
8530  if MeasDelay.get() == 1:
8531  txt = txt + " CB-A Delay = " + ' {0:.3f} '.format(CHBADelayR1) + " mS "
8532 
8533  x = X0L
8534  y = Y0T+GRH+int(2.5 *FontSize) # 20
8535  ca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
8536  if MeasTopV1.get() == 1 or MeasBaseV1.get() == 1 or MeasTopV2.get() == 1 or MeasBaseV2.get() == 1:
8537  MakeHistogram()
8538  txt = " "
8539  if ShowC1_V.get() == 1:
8540  # Channel A information
8541  if CHA_RC_HP.get() == 1:
8542  txt = "CHA: HP "
8543  else:
8544  txt = "CHA: "
8545  txt = txt + str(CH1pdvRange) + " V/div"
8546  if MeasDCV1.get() == 1:
8547  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV1)
8548  if MeasMaxV1.get() == 1:
8549  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV1)
8550  if MeasTopV1.get() == 1:
8551  txt = txt + " Top = " + ' {0:.4f} '.format(VATop)
8552  if MeasMinV1.get() == 1:
8553  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV1)
8554  if MeasBaseV1.get() == 1:
8555  txt = txt + " Base = " + ' {0:.4f} '.format(VABase)
8556  if MeasMidV1.get() == 1:
8557  MidV1 = (MaxV1+MinV1)/2.0
8558  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV1)
8559  if MeasPPV1.get() == 1:
8560  PPV1 = MaxV1-MinV1
8561  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV1)
8562  if MeasRMSV1.get() == 1:
8563  txt = txt + " RMS = " + ' {0:.4f} '.format(SV1)
8564  if MeasRMSVA_B.get() == 1:
8565  txt = txt + " A-B RMS = " + ' {0:.4f} '.format(SVA_B)
8566  if MeasDiffAB.get() == 1:
8567  txt = txt + " CA-CB = " + ' {0:.4f} '.format(DCV1-DCV2)
8568  if MeasUserA.get() == 1:
8569  try:
8570  TempValue = eval(UserAString)
8571  V1String = ' {0:.4f} '.format(TempValue)
8572  except:
8573  V1String = "####"
8574  txt = txt + UserALabel + " = " + V1String
8575  if (ShowC1_I.get() == 1 and ShowC1_V.get() == 0):
8576  txt = "CHA: "
8577  txt = txt + str(CH1IpdvRange) + " mA/div"
8578  elif (ShowC1_I.get() == 1 and ShowC1_V.get() == 1):
8579  txt = txt + "CHA: "
8580  txt = txt + str(CH1IpdvRange) + " mA/div"
8581  if ShowC1_I.get() == 1:
8582  if MeasDCI1.get() == 1:
8583  V1String = ' {0:.2f} '.format(DCI1)
8584  txt = txt + " AvgI = " + V1String
8585  if AWGAShape.get() == 0: # if this is a DC measurement calc resistance
8586  try:
8587  Resvalue = (DCV1/DCI1)*1000
8588  txt = txt + " Res = " + ' {0:.1f} '.format(Resvalue)
8589  except:
8590  txt = txt + " Res = OverRange"
8591  if MeasMaxI1.get() == 1:
8592  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI1)
8593  if MeasMinI1.get() == 1:
8594  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI1)
8595  if MeasMidI1.get() == 1:
8596  MidI1 = (MaxI1+MinI1)/2.0
8597  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI1)
8598  if MeasPPI1.get() == 1:
8599  PPI1 = MaxI1-MinI1
8600  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI1)
8601  if MeasRMSI1.get() == 1:
8602  txt = txt + " RMS = " + ' {0:.2f} '.format(SI1)
8603 
8604  x = X0L
8605  y = Y0T+GRH+(4*FontSize) # 32
8606  ca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
8607  txt= " "
8608  # Channel B information
8609  if MuxScreenStatus.get() == 1:
8610  txt = "CHB-Mux: "
8611  if Show_CBA.get() > 0:
8612  FindRisingEdge(VBuffA,VBuffMA)
8613  elif Show_CBB.get() > 0:
8614  FindRisingEdge(VBuffA,VBuffMB)
8615  elif Show_CBC.get() > 0:
8616  FindRisingEdge(VBuffA,VBuffMC)
8617  elif Show_CBD.get() > 0:
8618  FindRisingEdge(VBuffA,VBuffMD)
8619  if MeasPhase.get() == 1:
8620  txt = txt + " CA-Mux Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
8621  if MeasDelay.get() == 1:
8622  txt = txt + " Mux-CA Delay = " + ' {0:.3f} '.format(CHBADelayR1) + " mS "
8623  if MeasUserB.get() == 1:
8624  try:
8625  TempValue = eval(UserBString)
8626  V1String = ' {0:.4f} '.format(TempValue)
8627  except:
8628  V1String = "####"
8629  txt = txt + UserBLabel + " = " + V1String
8630  if ShowC2_V.get() == 1:
8631  if CHB_RC_HP.get() == 1:
8632  txt = "CHB: HP "
8633  else:
8634  txt = "CHB: "
8635  txt = txt + str(CH2pdvRange) + " V/div"
8636  if MeasDCV2.get() == 1:
8637  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV2)
8638  if MeasMaxV2.get() == 1:
8639  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV2)
8640  if MeasTopV2.get() == 1:
8641  txt = txt + " Top = " + ' {0:.4f} '.format(VBTop)
8642  if MeasMinV2.get() == 1:
8643  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV2)
8644  if MeasBaseV2.get() == 1:
8645  txt = txt + " Base = " + ' {0:.4f} '.format(VBBase)
8646  if MeasMidV2.get() == 1:
8647  MidV2 = (MaxV2+MinV2)/2.0
8648  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV2)
8649  if MeasPPV2.get() == 1:
8650  PPV2 = MaxV2-MinV2
8651  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV2)
8652  if MeasRMSV2.get() == 1:
8653  txt = txt + " RMS = " + ' {0:.4f} '.format(SV2)
8654  if MeasDiffBA.get() == 1:
8655  txt = txt + " CB-CA = " + ' {0:.4f} '.format(DCV2-DCV1)
8656  if MeasUserB.get() == 1:
8657  try:
8658  TempValue = eval(UserBString)
8659  V1String = ' {0:.4f} '.format(TempValue)
8660  except:
8661  V1String = "####"
8662  txt = txt + UserBLabel + " = " + V1String
8663  if (ShowC2_I.get() == 1 and ShowC2_V.get() == 0):
8664  txt = "CHB: "
8665  txt = txt + str(CH2IpdvRange) + " mA/div"
8666  elif (ShowC2_I.get() == 1 and ShowC2_V.get() == 1):
8667  txt = txt + "CHB: "
8668  txt = txt + str(CH2IpdvRange) + " mA/div"
8669  if ShowC2_I.get() == 1:
8670  if MeasDCI2.get() == 1:
8671  V1String = ' {0:.2f} '.format(DCI2)
8672  txt = txt + " AvgI = " + V1String
8673  if AWGBShape.get() == 0: # if this is a DC measurement calc resistance
8674  try:
8675  Resvalue = (DCV2/DCI2)*1000
8676  R1String = ' {0:.1f} '.format(Resvalue)
8677  txt = txt + " Res = " + R1String
8678  except:
8679  txt = txt + " Res = OverRange"
8680  if MeasMaxI2.get() == 1:
8681  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI2)
8682  if MeasMinI2.get() == 1:
8683  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI2)
8684  if MeasMidI2.get() == 1:
8685  MidI2 = (MaxI2+MinI2)/2.0
8686  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI2)
8687  if MeasPPI2.get() == 1:
8688  PPI2 = MaxI2-MinI2
8689  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI2)
8690  if MeasRMSI2.get() == 1:
8691  txt = txt + " RMS = " + ' {0:.2f} '.format(SI2)
8692 
8693  x = X0L
8694  y = Y0T+GRH+int(5.5*FontSize) # 44
8695  ca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
8696 
8697 def MakeXYScreen():
8698  global XYlineVA, XYlineIA, XYlineVB, XYlineIB, XYlineM, XYlineMX, XYlineMY # active trave lines
8699  global Tmathline, TMRline, XYRlineVA, XYRlineIA, XYRlineVB, XYRlineIB, XYRlineM, XYRlineMX, XYRlineMY
8700  global X0LXY # Left top X value
8701  global Y0TXY # Left top Y value
8702  global GRWXY # Screenwidth
8703  global GRHXY # Screenheight
8704  global FontSize, LabelPlotText, PlotLabelText
8705  global XYca, MouseX, MouseY, MouseWidget
8706  global ShowXCur, ShowYCur, XCursor, YCursor
8707  global SHOWsamples # Number of samples in data record
8708  global ShowMath, MathUnits, MathXUnits, MathYUnits
8709  global Xsignal, MathAxis, MathXAxis, MathYAxis
8710  global YsignalVA, YsignalIA, YsignalVB, YsignalIB, YsignalM, YsignalMY, YsignalMX
8711  global XYRefAV, XYRefAI, XYRefBV, XYRefBI, XYRefM, XYRefMX, XYRefMY
8712  global RUNstatus, SingleShot, ManualTrigger # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
8713  global CHAsbxy # spinbox Index for channel 1 V
8714  global CHBsbxy # spinbox Index for channel 2 V
8715  global CHAOffset # Offset value for channel 1 V
8716  global CHBOffset # Offset value for channel 2 V
8717  global CHAIsbxy # spinbox Index for channel 1 I
8718  global CHBIsbxy # spinbox Index for channel 2 I
8719  global CHAIOffset # Offset value for channel 1 I
8720  global CHBIOffset # Offset value for channel 2 I
8721  global TMpdiv # Array with time / div values in ms
8722  global TMsb # Time per div spin box variable
8723  global TIMEdiv # current spin box value
8724  global SAMPLErate
8725  global TRIGGERsample, TRIGGERlevel, HoldOff, HoldOffentry
8726  global COLORgrid, COLORzeroline, COLORtext, COLORtrigger, COLORtrace6, COLORtrace7 # The colors
8727  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5
8728  global COLORtraceR1, COLORtraceR2, COLORtraceR3, COLORtraceR4, COLORtraceR5, COLORtraceR6, COLORtraceR7
8729  global CANVASwidthXY, CANVASheightXY, COLORXmarker, COLORYmarker
8730  global TRACErefresh, TRACEmode, TRACEwidth, GridWidth
8731  global ScreenXYrefresh, SmoothCurves
8732  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2, CHAHW, CHALW, CHADCy, CHAperiod, CHAfreq
8733  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2, CHBHW, CHBLW, CHBDCy, CHBperiod, CHBfreq
8734  global SV1, SI1, SV2, SI2, CHABphase
8735  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1
8736  global MeasDCI1, MeasMinI1, MeasMaxI1, MeasMidI1, MeasPPI1
8737  global MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2, MeasPPV2
8738  global MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2
8739  global MeasRMSV1, MeasRMSI1, MeasRMSV2, MeasRMSI2, MeasPhase
8740  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ
8741  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
8742  global AWGAShape, AWGBShape
8743  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
8744  global CHAVPosEntry, CHAIPosEntry, CHAVPosEntry, CHBIPosEntry
8745  global CH1pdvRange, CHAOffset, CH2pdvRange, CHBOffset
8746  global DacScreenStatus, DigScreenStatus
8747  global D0, D1, D2, D3, D4, D5, D6, D7
8748  global DevID, devx, MarkerNum, MarkerScale
8749  global HozPoss, HozPossentry
8750  global HistAsPercent, VBuffA, VBuffB, HBuffA, HBuffB
8751  global VABase, VATop, VBBase, VBTop, UserALabel, UserAString, UserBLabel, UserBString
8752  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2, MeasUserA, MeasUserB
8753  #
8754  Ymin = Y0TXY # Minimum position of screen grid (top)
8755  Ymax = Y0TXY + GRHXY # Maximum position of screen grid (bottom)
8756  RightOffset = FontSize * 3
8757  LeftOffset = int(FontSize/2)
8758  try:
8759  InOffA = float(eval(CHAVOffsetEntry.get()))
8760  except:
8761  CHAVOffsetEntry.delete(0,END)
8762  CHAVOffsetEntry.insert(0, InOffA)
8763  try:
8764  InGainA = float(eval(CHAVGainEntry.get()))
8765  except:
8766  CHAVGainEntry.delete(0,END)
8767  CHAVGainEntry.insert(0, InGainA)
8768  try:
8769  InOffB = float(eval(CHBVOffsetEntry.get()))
8770  except:
8771  CHBVOffsetEntry.delete(0,END)
8772  CHBVOffsetEntry.insert(0, InOffB)
8773  try:
8774  InGainB = float(eval(CHBVGainEntry.get()))
8775  except:
8776  CHBVGainEntry.delete(0,END)
8777  CHBVGainEntry.insert(0, InGainB)
8778 #
8779  try:
8780  CH1pdvRange = float(eval(CHAsbxy.get()))
8781  except:
8782  CHAsbxy.delete(0,END)
8783  CHAsbxy.insert(0, CH1pdvRange)
8784  try:
8785  CH2pdvRange = float(eval(CHBsbxy.get()))
8786  except:
8787  CHBsbxy.delete(0,END)
8788  CHBsbxy.insert(0, CH2pdvRange)
8789  try:
8790  CH1IpdvRange = float(eval(CHAIsbxy.get()))
8791  except:
8792  CHAIsbxy.delete(0,END)
8793  CHAIsbxy.insert(0, CH1IpdvRange)
8794  try:
8795  CH2IpdvRange = float(eval(CHBIsbxy.get()))
8796  except:
8797  CHBIsbxy.delete(0,END)
8798  CHBIsbxy.insert(0, CH2IpdvRange)
8799  # get the vertical offsets
8800  try:
8801  CHAOffset = float(eval(CHAVPosEntryxy.get()))
8802  except:
8803  CHAVPosEntryxy.delete(0,END)
8804  CHAVPosEntryxy.insert(0, CHAOffset)
8805  try:
8806  CHAIOffset = float(eval(CHAIPosEntryxy.get()))
8807  except:
8808  CHAIPosEntryxy.delete(0,END)
8809  CHAIPosEntryxy.insert(0, CHAIOffset)
8810  try:
8811  CHBOffset = float(eval(CHBVPosEntryxy.get()))
8812  except:
8813  CHBVPosEntry.delete(0,END)
8814  CHBVPosEntry.insert(0, CHBOffset)
8815  try:
8816  CHBIOffset = float(eval(CHBIPosEntryxy.get()))
8817  except:
8818  CHBIPosEntryxy.delete(0,END)
8819  CHBIPosEntryxy.insert(0, CHBIOffset)
8820  # prevent divide by zero error
8821  if CH1pdvRange < 0.001:
8822  CH1pdvRange = 0.001
8823  if CH2pdvRange < 0.001:
8824  CH2pdvRange = 0.001
8825  if CH1IpdvRange < 0.05:
8826  CH1IpdvRange = 0.05
8827  if CH2IpdvRange < 0.05:
8828  CH2IpdvRange = 0.05
8829  # If drawing histograms adjust offset based on range such that bottom grid is zero
8830  if Xsignal.get() == 6:
8831  CHAIOffset = 5 * CH1IpdvRange
8832  if Xsignal.get() == 7:
8833  CHBIOffset = 5 * CH2IpdvRange
8834  if ScreenXYrefresh.get() == 0:
8835  # Delete all items on the screen
8836  MarkerNum = 0
8837  XYca.delete(ALL) # remove all items
8838  # Draw horizontal grid lines
8839  i = 0
8840  x1 = X0LXY
8841  x2 = X0LXY + GRWXY
8842  mg_siz = GRWXY/10.0
8843  mg_inc = mg_siz/5.0
8844  while (i < 11):
8845  y = Y0TXY + i * GRHXY/10.0
8846  Dline = [x1,y,x2,y]
8847  if i == 5:
8848  XYca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue line at center of grid
8849  k = 0
8850  while (k < 10):
8851  l = 1
8852  while (l < 5):
8853  Dline = [x1+k*mg_siz+l*mg_inc,y-5,x1+k*mg_siz+l*mg_inc,y+5]
8854  XYca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
8855  l = l + 1
8856  k = k + 1
8857  else:
8858  XYca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
8859  if YsignalIA.get() == 1 or Xsignal.get() == 6:
8860  Iaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
8861  Iaxis_label = str(round(Iaxis_value, 3))
8862  XYca.create_text(x2+LeftOffset, y, text=Iaxis_label, fill=COLORtrace3, anchor="w", font=("arial", FontSize ))
8863  if YsignalIB.get() == 1 or Xsignal.get() == 7:
8864  Iaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
8865  Iaxis_label = str(round(Iaxis_value, 3))
8866  XYca.create_text(x2+RightOffset, y, text=Iaxis_label, fill=COLORtrace4, anchor="w", font=("arial", FontSize ))
8867  if YsignalVA.get() == 1:
8868  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8869  Vaxis_label = str(round(Vaxis_value, 3))
8870  XYca.create_text(x1-LeftOffset, y, text=Vaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
8871  if YsignalVB.get() == 1:
8872  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
8873  Vaxis_label = str(round(Vaxis_value, 3))
8874  XYca.create_text(x1-RightOffset, y, text=Vaxis_label, fill=COLORtrace2, anchor="e", font=("arial", FontSize ))
8875  if YsignalM.get() == 1:
8876  TempCOLOR = COLORtrace5
8877  if MathTrace.get() == 2:
8878  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8879  elif MathTrace.get() == 3:
8880  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
8881  else:
8882  if MathAxis == "V-A":
8883  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8884  TempCOLOR = COLORtrace1
8885  elif MathAxis == "V-B":
8886  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
8887  TempCOLOR = COLORtrace2
8888  elif MathAxis == "I-A":
8889  Vaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
8890  TempCOLOR = COLORtrace3
8891  elif MathAxis == "I-B":
8892  Vaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
8893  TempCOLOR = COLORtrace4
8894  else:
8895  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8896  Vaxis_label = str(round(Vaxis_value, 3))
8897  XYca.create_text(x1-RightOffset, y, text=Vaxis_label, fill=TempCOLOR, anchor="e", font=("arial", FontSize ))
8898  if YsignalMX.get() == 1:
8899  TempCOLOR = COLORtrace6
8900  if MathXAxis == "V-A":
8901  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8902  TempCOLOR = COLORtrace1
8903  elif MathXAxis == "V-B":
8904  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
8905  TempCOLOR = COLORtrace2
8906  elif MathXAxis == "I-A":
8907  Vaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
8908  TempCOLOR = COLORtrace3
8909  elif MathXAxis == "I-B":
8910  Vaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
8911  TempCOLOR = COLORtrace4
8912  else:
8913  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8914  Vaxis_label = str(round(Vaxis_value, 3))
8915  XYca.create_text(x1-RightOffset, y, text=Vaxis_label, fill=TempCOLOR, anchor="e", font=("arial", FontSize ))
8916  if YsignalMY.get() == 1:
8917  TempCOLOR = COLORtrace7
8918  if MathYAxis == "V-A":
8919  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8920  TempCOLOR = COLORtrace1
8921  elif MathYAxis == "V-B":
8922  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
8923  TempCOLOR = COLORtrace2
8924  elif MathYAxis == "I-A":
8925  Vaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
8926  TempCOLOR = COLORtrace3
8927  elif MathYAxis == "I-B":
8928  Vaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
8929  TempCOLOR = COLORtrace4
8930  else:
8931  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8932  Vaxis_label = str(round(Vaxis_value, 3))
8933  XYca.create_text(x1-RightOffset, y, text=Vaxis_label, fill=TempCOLOR, anchor="e", font=("arial", FontSize ))
8934  i = i + 1
8935  # Draw vertical grid lines
8936  i = 0
8937  y1 = Y0TXY
8938  y2 = Y0TXY + GRHXY
8939  mg_siz = GRHXY/10.0
8940  mg_inc = mg_siz/5.0
8941  #
8942  while (i < 11):
8943  x = X0LXY + i * GRWXY/10.0
8944  Dline = [x,y1,x,y2]
8945  if (i == 5):
8946  XYca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue vertical line at center of grid
8947  k = 0
8948  while (k < 10):
8949  l = 1
8950  while (l < 5):
8951  Dline = [x-5,y1+k*mg_siz+l*mg_inc,x+5,y1+k*mg_siz+l*mg_inc]
8952  XYca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
8953  l = l + 1
8954  k = k + 1
8955  if Xsignal.get() == 1 or Xsignal.get() == 6: #
8956  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
8957  Vaxis_label = str(round(Vaxis_value, 3))
8958  XYca.create_text(x, y2+3, text=Vaxis_label, fill=COLORtrace1, anchor="n", font=("arial", FontSize ))
8959  elif Xsignal.get() == 3 or Xsignal.get() == 7:
8960  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
8961  Vaxis_label = str(round(Vaxis_value, 3))
8962  XYca.create_text(x, y2+3, text=Vaxis_label, fill=COLORtrace2, anchor="n", font=("arial", FontSize ))
8963  elif Xsignal.get() == 2:
8964  Iaxis_value = 1.0 * (((i-5) * CH1IpdvRange ) + CHAIOffset)
8965  Iaxis_label = str(round(Iaxis_value, 3))
8966  XYca.create_text(x, y2+3, text=Iaxis_label, fill=COLORtrace3, anchor="n", font=("arial", FontSize ))
8967  elif Xsignal.get() == 4:
8968  Iaxis_value = 1.0 * (((i-5) * CH2IpdvRange ) + CHBIOffset)
8969  Iaxis_label = str(round(Iaxis_value, 3))
8970  XYca.create_text(x, y2+3, text=Iaxis_label, fill=COLORtrace4, anchor="n", font=("arial", FontSize ))
8971  elif Xsignal.get() == 5:
8972  TempCOLOR = COLORtrace5
8973  if MathTrace.get() == 2:
8974  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
8975  elif MathTrace.get() == 3:
8976  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
8977  else:
8978  if MathXAxis == "V-A":
8979  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
8980  TempCOLOR = COLORtrace1
8981  elif MathXAxis == "V-B":
8982  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
8983  TempCOLOR = COLORtrace2
8984  elif MathXAxis == "I-A":
8985  Vaxis_value = 1.0 * (((i-5) * CH1IpdvRange ) + CHAIOffset)
8986  TempCOLOR = COLORtrace3
8987  elif MathXAxis == "I-B":
8988  Vaxis_value = 1.0 * (((i-5) * CH2IpdvRange ) + CHBIOffset)
8989  TempCOLOR = COLORtrace4
8990  else:
8991  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
8992  TempCOLOR = COLORtrace5
8993  Vaxis_label = str(round(Vaxis_value, 3))
8994  XYca.create_text(x, y2+3, text=Vaxis_label, fill=TempCOLOR, anchor="n", font=("arial", FontSize ))
8995  else:
8996  XYca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
8997  if Xsignal.get() == 1 or Xsignal.get() == 6:
8998  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
8999  Vaxis_label = str(round(Vaxis_value, 3))
9000  XYca.create_text(x, y2+3, text=Vaxis_label, fill=COLORtrace1, anchor="n", font=("arial", FontSize ))
9001  elif Xsignal.get() == 3 or Xsignal.get() == 7:
9002  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
9003  Vaxis_label = str(round(Vaxis_value, 3))
9004  XYca.create_text(x, y2+3, text=Vaxis_label, fill=COLORtrace2, anchor="n", font=("arial", FontSize ))
9005  elif Xsignal.get() == 2:
9006  Iaxis_value = 1.0 * (((i-5) * CH1IpdvRange ) + CHAIOffset)
9007  Iaxis_label = str(round(Iaxis_value, 3))
9008  XYca.create_text(x, y2+3, text=Iaxis_label, fill=COLORtrace3, anchor="n", font=("arial", FontSize ))
9009  elif Xsignal.get() == 4:
9010  Iaxis_value = 1.0 * (((i-5) * CH2IpdvRange ) + CHBIOffset)
9011  Iaxis_label = str(round(Iaxis_value, 3))
9012  XYca.create_text(x, y2+3, text=Iaxis_label, fill=COLORtrace4, anchor="n", font=("arial", FontSize ))
9013  elif Xsignal.get() == 5:
9014  TempCOLOR = COLORtrace5
9015  if MathTrace.get() == 2:
9016  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
9017  elif MathTrace.get() == 3:
9018  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
9019  else:
9020  if MathXAxis == "V-A":
9021  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
9022  TempCOLOR = COLORtrace1
9023  elif MathXAxis == "V-B":
9024  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
9025  TempCOLOR = COLORtrace2
9026  elif MathXAxis == "I-A":
9027  Vaxis_value = 1.0 * (((i-5) * CH1IpdvRange ) + CHAIOffset)
9028  TempCOLOR = COLORtrace3
9029  elif MathXAxis == "I-B":
9030  Vaxis_value = 1.0 * (((i-5) * CH2IpdvRange ) + CHBIOffset)
9031  TempCOLOR = COLORtrace4
9032  else:
9033  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
9034  Vaxis_label = str(round(Vaxis_value, 3))
9035  XYca.create_text(x, y2+3, text=Vaxis_label, fill=TempCOLOR, anchor="n", font=("arial", FontSize ))
9036  i = i + 1
9037 # Draw traces
9038 # Avoid writing lines with 1 coordinate
9039  if YsignalVA.get() == 1:
9040  if len(XYlineVA) > 4:
9041  XYca.create_line(XYlineVA, fill=COLORtrace1, width=TRACEwidth.get())
9042  if YsignalIA.get() == 1:
9043  if len(XYlineIA) > 4:
9044  XYca.create_line(XYlineIA, fill=COLORtrace3, width=TRACEwidth.get())
9045  if YsignalVB.get() == 1:
9046  if len(XYlineVB) > 4:
9047  XYca.create_line(XYlineVB, fill=COLORtrace2, width=TRACEwidth.get())
9048  if YsignalIB.get() == 1:
9049  if len(XYlineIB) > 4:
9050  XYca.create_line(XYlineIB, fill=COLORtrace4, width=TRACEwidth.get())
9051  if YsignalM.get() == 1: # or Ysignal.get() == 5:
9052  if len(XYlineM) > 4:
9053  XYca.create_line(XYlineM, fill=COLORtrace5, width=TRACEwidth.get())
9054  if YsignalMX.get() == 1:
9055  if len(XYlineMX) > 4:
9056  XYca.create_line(XYlineMX, fill=COLORtrace6, width=TRACEwidth.get())
9057  if YsignalMY.get() == 1:
9058  if len(XYlineMY) > 4:
9059  XYca.create_line(XYlineMY, fill=COLORtrace7, width=TRACEwidth.get())
9060  if len(XYRlineVA) > 4 and XYRefAV.get() == 1:
9061  XYca.create_line(XYRlineVA, fill=COLORtraceR1, width=TRACEwidth.get())
9062  if len(XYRlineVB) > 4 and XYRefBV.get() == 1:
9063  XYca.create_line(XYRlineVB, fill=COLORtraceR2, width=TRACEwidth.get())
9064  if len(XYRlineIA) > 4 and XYRefAI.get() == 1:
9065  XYca.create_line(XYRlineIA, fill=COLORtraceR3, width=TRACEwidth.get())
9066  if len(XYRlineIB) > 4 and XYRefBI.get() == 1:
9067  XYca.create_line(XYRlineIB, fill=COLORtraceR4, width=TRACEwidth.get())
9068  if len(XYRlineM) > 4 and XYRefM.get() == 1:
9069  XYca.create_line(XYRlineM, fill=COLORtraceR5, width=TRACEwidth.get())
9070  if len(XYRlineMX) > 4 and XYRefMX.get() == 1:
9071  XYca.create_line(XYRlineMX, fill=COLORtraceR6, width=TRACEwidth.get())
9072  if len(XYRlineMY) > 4 and XYRefMY.get() == 1:
9073  XYca.create_line(XYRlineMY, fill=COLORtraceR7, width=TRACEwidth.get())
9074 # Draw Histogram Traces
9075  if Xsignal.get() == 6:
9076  MakeHistogram()
9077  b = 0
9078  Yconv1 = float(GRHXY/10.0) / CH1IpdvRange
9079  Xconv1 = float(GRWXY/10.0) / CH1pdvRange
9080  y1 = Y0TXY + GRHXY
9081  c2 = GRWXY / 2.0 + X0LXY # Hor correction factor
9082  while b < 4999: #
9083  if HistAsPercent == 1: # convert to percent of total sample count
9084  ylo = float(HBuffA[0][b]) / len(VBuffA)
9085  ylo = ylo * 100.0
9086  else:
9087  ylo = HBuffA[0][b] #
9088  ylo = int(y1 - (Yconv1 * ylo))
9089  if ylo > Ymax:
9090  ylo = Ymax
9091  if ylo < Ymin:
9092  ylo = Ymin
9093  xlo = HBuffA[1][b] - CHAOffset
9094  xlo = int(c2 + Xconv1 * xlo)
9095  Dline = [xlo,y1,xlo,ylo]
9096  XYca.create_line(Dline, fill=COLORtrace1, width=TRACEwidth.get())
9097  b = b + 1
9098  if Xsignal.get() == 7:
9099  MakeHistogram()
9100  b = 0
9101  Yconv1 = float(GRHXY/10.0) / CH2IpdvRange
9102  Xconv1 = float(GRWXY/10.0) / CH2pdvRange
9103  y1 = Y0TXY + GRHXY
9104  c2 = GRWXY / 2.0 + X0LXY # Hor correction factor
9105  while b < 4999: #
9106  if HistAsPercent == 1: # convert to percent
9107  ylo = float(HBuffB[0][b]) / len(VBuffB)
9108  ylo = ylo * 100.0
9109  else:
9110  ylo = HBuffB[0][b]
9111  ylo = int(y1 - Yconv1 * ylo)
9112  if ylo > Ymax:
9113  ylo = Ymax
9114  if ylo < Ymin:
9115  ylo = Ymin
9116  xlo = HBuffB[1][b] - CHBOffset
9117  xlo = int(c2 + Xconv1 * xlo)
9118  Dline = [xlo,y1,xlo,ylo]
9119  XYca.create_line(Dline, fill=COLORtrace2, width=TRACEwidth.get())
9120  b = b + 1
9121 # Draw X - Y Cursor lines if required
9122  COLORXmarker = COLORtrace1
9123  COLORYmarker = COLORtrace2
9124  Xconv1 = float(GRWXY/10) / CH1pdvRange
9125  Xoffset1 = CHAOffset
9126  X_label = " V"
9127  if Xsignal.get() == 1 or Xsignal.get() == 6:
9128  Xconv1 = float(GRWXY/10) / CH1pdvRange
9129  Xoffset1 = CHAOffset
9130  COLORXmarker = COLORtrace1
9131  X_label = " V"
9132  if Xsignal.get() == 2:
9133  Xconv1 = float(GRWXY/10) / CH1IpdvRange
9134  Xoffset1 = CHAIOffset
9135  COLORXmarker = COLORtrace3
9136  X_label = " mA"
9137  if Xsignal.get() == 3 or Xsignal.get() == 7:
9138  Xconv1 = float(GRWXY/10) / CH2pdvRange
9139  Xoffset1 = CHBOffset
9140  COLORXmarker = COLORtrace2
9141  X_label = " V"
9142  if Xsignal.get() == 4:
9143  Xconv1 = float(GRWXY/10) / CH2IpdvRange
9144  Xoffset1 = CHBIOffset
9145  COLORmarker = COLORtrace4
9146  X_label = " mA"
9147  if Xsignal.get() == 5:
9148  X_label = MathXUnits
9149  if MathXAxis == "V-A":
9150  Xconv1 = float(GRWXY/10) / CH1pdvRange
9151  Xoffset1 = CHAOffset
9152  COLORXmarker = COLORtrace1
9153  elif MathXAxis == "V-B":
9154  Xconv1 = float(GRWXY/10) / CH2pdvRange
9155  Xoffset1 = CHBOffset
9156  COLORXmarker = COLORtrace2
9157  elif MathXAxis == "I-A":
9158  Xconv1 = float(GRWXY/10) / CH1IpdvRange
9159  Xoffset1 = CHAIOffset
9160  COLORXmarker = COLORtrace3
9161  elif MathXAxis == "I-B":
9162  Xconv1 = float(GRWXY/10) / CH2IpdvRange
9163  Xoffset1 = CHBIOffset
9164  COLORXmarker = COLORtrace4
9165  else:
9166  Xconv1 = float(GRWXY/10) / CH1pdvRange
9167  Xoffset1 = CHAOffset
9168  COLORXmarker = COLORtrace1
9169 # Set variables just incase
9170  Yconv1 = float(GRHXY/10.0) / CH1pdvRange
9171  Yoffset1 = CHAOffset
9172  Y_label = " V"
9173  if YsignalVA.get() == 1 or YsignalM.get() == 1:
9174  Yconv1 = float(GRHXY/10.0) / CH1pdvRange
9175  Yoffset1 = CHAOffset
9176  COLORYmarker = COLORtrace1
9177  Y_label = " V"
9178  if YsignalIA.get() == 1:
9179  Yconv1 = float(GRHXY/10.0) / CH1IpdvRange
9180  Yoffset1 = CHAIOffset
9181  COLORYmarker = COLORtrace3
9182  Y_label = " mA"
9183  if YsignalVB.get() == 1 or YsignalM.get() == 1:
9184  Yconv1 = float(GRHXY/10.0) / CH2pdvRange
9185  Yoffset1 = CHBOffset
9186  COLORYmarker = COLORtrace2
9187  Y_label = " V"
9188  if YsignalIB.get() == 1:
9189  Yconv1 = float(GRHXY/10.0) / CH2IpdvRange
9190  Yoffset1 = CHBIOffset
9191  COLORYmarker = COLORtrace4
9192  Y_label = " mA"
9193  if YsignalM.get() == 1 or YsignalMX.get() == 1 or YsignalMY.get() == 1:
9194  Y_label = MathYUnits
9195  if MathYAxis == "V-A":
9196  Yconv1 = float(GRHXY/10.0) / CH1pdvRange
9197  Yoffset1 = CHAOffset
9198  COLORYmarker = COLORtrace1
9199  elif MathYAxis == "V-B":
9200  Yconv1 = float(GRHXY/10.0) / CH2pdvRange
9201  Yoffset1 = CHBOffset
9202  COLORYmarker = COLORtrace2
9203  elif MathYAxis == "I-A":
9204  Yconv1 = float(GRHXY/10.0) / CH1IpdvRange
9205  Yoffset1 = CHAIOffset
9206  COLORYmarker = COLORtrace3
9207  elif MathYAxis == "I-B":
9208  Yconv1 = float(GRHXY/10.0) / CH2IpdvRange
9209  Yoffset1 = CHBIOffset
9210  COLORYmarker = COLORtrace4
9211  else:
9212  Yconv1 = float(GRHXY/10.0) / CH1pdvRange
9213  Yoffset1 = CHAOffset
9214  COLORYmarker = COLORtrace1
9215  if ShowXCur.get() > 0:
9216  Dline = [XCursor, Y0TXY, XCursor, Y0TXY+GRHXY]
9217  XYca.create_line(Dline, dash=(4,3), fill=COLORXmarker, width=GridWidth.get())
9218  c1 = GRWXY / 2.0 + X0LXY # fixed X correction
9219  xvolts = Xoffset1 - ((c1-XCursor)/Xconv1)
9220  XString = ' {0:.3f} '.format(xvolts)
9221  V_label = XString + X_label
9222  XYca.create_text(XCursor+1, YCursor-5, text=V_label, fill=COLORXmarker, anchor="w", font=("arial", FontSize ))
9223  if ShowYCur.get() > 0:
9224  Dline = [X0LXY, YCursor, X0LXY+GRWXY, YCursor]
9225  XYca.create_line(Dline, dash=(4,3), fill=COLORYmarker, width=GridWidth.get())
9226  c1 = GRHXY / 2.0 + Y0TXY # fixed Y correction
9227  yvolts = ((YCursor-c1)/Yconv1) - Yoffset1
9228  V1String = ' {0:.3f} '.format(-yvolts)
9229  V_label = V1String + Y_label
9230  XYca.create_text(XCursor+1, YCursor+5, text=V_label, fill=COLORYmarker, anchor="w", font=("arial", FontSize ))
9231  if ShowXCur.get() == 0 and ShowYCur.get() == 0 and MouseWidget == XYca:
9232  if MouseX > X0LXY and MouseX < X0LXY+GRWXY and MouseY > Y0TXY and MouseY < Y0TXY+GRHXY:
9233  Dline = [MouseX, Y0TXY, MouseX, Y0TXY+GRHXY]
9234  XYca.create_line(Dline, dash=(4,3), fill=COLORXmarker, width=GridWidth.get())
9235  c1 = GRWXY / 2.0 + X0LXY # fixed X correction
9236  xvolts = Xoffset1 - ((c1-MouseX)/Xconv1) # XCursor
9237  XString = ' {0:.3f} '.format(xvolts)
9238  V_label = XString + X_label
9239  XYca.create_text(MouseX+1, MouseY-5, text=V_label, fill=COLORXmarker, anchor="w", font=("arial", FontSize ))
9240  Dline = [X0LXY, MouseY, X0LXY+GRWXY, MouseY]
9241  XYca.create_line(Dline, dash=(4,3), fill=COLORYmarker, width=GridWidth.get())
9242  c1 = GRHXY / 2 + Y0TXY # fixed Y correction
9243  yvolts = ((MouseY-c1)/Yconv1) - Yoffset1
9244  V1String = ' {0:.3f} '.format(-yvolts)
9245  V_label = V1String + Y_label
9246  XYca.create_text(MouseX+1, MouseY+5, text=V_label, fill=COLORYmarker, anchor="w", font=("arial", FontSize ))
9247 #
9248 # General information on top of the grid
9249 # Sweep information
9250  sttxt = "Running"
9251  if TRACEmodeTime.get() == 1:
9252  sttxt = sttxt + " Averaging"
9253  if ManualTrigger.get() == 1:
9254  sttxt = "Manual Trigger"
9255  if (RUNstatus.get() == 0) or (RUNstatus.get() == 3):
9256  sttxt = "Stopped"
9257  if ScreenXYrefresh.get() == 1:
9258  sttxt = sttxt + " Persistance ON"
9259  # Delete text at bottom of screen
9260  de = XYca.find_enclosed( X0LXY-1, Y0TXY+GRHXY+19, CANVASwidthXY, Y0TXY+GRHXY+100)
9261  for n in de:
9262  XYca.delete(n)
9263  # Delete text at top of screen
9264  de = XYca.find_enclosed( X0LXY-1, -1, CANVASwidthXY, 20)
9265  for n in de:
9266  XYca.delete(n)
9267  if LabelPlotText.get() > 0:
9268  txt = PlotLabelText + " Sample rate: " + str(SAMPLErate) + " " + sttxt
9269  else:
9270  txt = "Device ID " + DevID[17:31] + " Sample rate: " + str(SAMPLErate) + " " + sttxt
9271  x = X0LXY
9272  y = 12
9273  XYca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
9274  # digital I/O indicators
9275  x2 = X0LXY + GRWXY
9276  BoxColor = "#808080" # gray
9277  if DacScreenStatus.get() == 0 and DigScreenStatus.get() == 1 :
9278  if D0.get() == 0 and D4.get() == 0:
9279  Dval = devx.ctrl_transfer( 0xc0, 0x91, 4, 0, 0, 1, 100)
9280  if Dval[0] == 1:
9281  BoxColor = "#00ff00" # 100% green
9282  elif Dval[0] == 0:
9283  BoxColor = "#ff0000" # 100% red
9284  XYca.create_rectangle(x2-12, 6, x2, 18, fill=BoxColor)
9285  else:
9286  XYca.create_rectangle(x2-12, 6, x2, 18, fill="yellow")
9287  if D1.get() == 0 and D5.get() == 0:
9288  Dval = devx.ctrl_transfer( 0xc0, 0x91, 5, 0, 0, 1, 100)
9289  if Dval[0] == 1:
9290  BoxColor = "#00ff00" # 100% green
9291  elif Dval[0] == 0:
9292  BoxColor = "#ff0000" # 100% red
9293  XYca.create_rectangle(x2-26, 6, x2-14, 18, fill=BoxColor)
9294  else:
9295  XYca.create_rectangle(x2-26, 6, x2-14, 18, fill="yellow")
9296  if D2.get() == 0 and D6.get() == 0:
9297  Dval = devx.ctrl_transfer( 0xc0, 0x91, 6, 0, 0, 1, 100)
9298  if Dval[0] == 1:
9299  BoxColor = "#00ff00" # 100% green
9300  elif Dval[0] == 0:
9301  BoxColor = "#ff0000" # 100% red
9302  XYca.create_rectangle(x2-40, 6, x2-28, 18, fill=BoxColor)
9303  else:
9304  XYca.create_rectangle(x2-40, 6, x2-28, 18, fill="yellow")
9305  if D3.get() == 0 and D7.get() == 0:
9306  Dval = devx.ctrl_transfer( 0xc0, 0x91, 7, 0, 0, 1, 100)
9307  if Dval[0] == 1:
9308  BoxColor = "#00ff00" # 100% green
9309  elif Dval[0] == 0:
9310  BoxColor = "#ff0000" # 100% red
9311  XYca.create_rectangle(x2-54, 6, x2-42, 18, fill=BoxColor)
9312  else:
9313  XYca.create_rectangle(x2-54, 6, x2-42, 18, fill="yellow")
9314  XYca.create_text(x2-56, 12, text="Digital Inputs", anchor=E, fill=COLORtext, font=("arial", FontSize ))
9315  # print period and frequency of displayed channels
9316  txt = " "
9317  if Xsignal.get() == 1 or Xsignal.get() == 3:
9318  FindRisingEdge(VBuffA, VBuffB)
9319  if Xsignal.get() == 1:
9320  if MeasAHW.get() == 1:
9321  txt = txt + " CA Hi Width = " + ' {0:.2f} '.format(CHAHW) + " mS "
9322  if MeasALW.get() == 1:
9323  txt = txt + " CA Lo Width = " + ' {0:.2f} '.format(CHALW) + " mS "
9324  if MeasADCy.get() == 1:
9325  txt = txt + " CA DutyCycle = " + ' {0:.1f} '.format(CHADCy) + " % "
9326  if MeasAPER.get() == 1:
9327  txt = txt + " CA Period = " + ' {0:.2f} '.format(CHAperiod) + " mS "
9328  if MeasAFREQ.get() == 1:
9329  txt = txt + " CA Freq = " + ' {0:.1f} '.format(CHAfreq) + " Hz "
9330  if Xsignal.get() == 3:
9331  if MeasBHW.get() == 1:
9332  txt = txt + " CB Hi Width = " + ' {0:.2f} '.format(CHBHW) + " mS "
9333  if MeasBLW.get() == 1:
9334  txt = txt + " CB Lo Width = " + ' {0:.2f} '.format(CHBLW) + " mS "
9335  if MeasBDCy.get() == 1:
9336  txt = txt + " CB DutyCycle = " + ' {0:.1f} '.format(CHBDCy) + " % "
9337  if MeasBPER.get() == 1:
9338  txt = txt + " CB Period = " + ' {0:.2f} '.format(CHBperiod) + " mS "
9339  if MeasBFREQ.get() == 1:
9340  txt = txt + " CB Freq = " + ' {0:.1f} '.format(CHBfreq) + " Hz "
9341  if MeasPhase.get() == 1:
9342  txt = txt + " CA-B Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
9343 
9344  x = X0LXY
9345  y = Y0TXY+GRHXY+int(2.5*FontSize) # 20
9346  XYca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
9347  txt = " "
9348  if Xsignal.get() == 1 or YsignalVA.get() == 1 or Xsignal.get() == 6:
9349  # Channel A information
9350  txt = "CHA: "
9351  txt = txt + str(CH1pdvRange) + " V/div"
9352  if MeasDCV1.get() == 1:
9353  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV1)
9354  if MeasMaxV1.get() == 1:
9355  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV1)
9356  if MeasTopV1.get() == 1:
9357  txt = txt + " Top = " + ' {0:.4f} '.format(VATop)
9358  if MeasMinV1.get() == 1:
9359  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV1)
9360  if MeasBaseV1.get() == 1:
9361  txt = txt + " Top = " + ' {0:.4f} '.format(VABase)
9362  if MeasMidV1.get() == 1:
9363  MidV1 = (MaxV1+MinV1)/2
9364  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV1)
9365  if MeasPPV1.get() == 1:
9366  PPV1 = MaxV1-MinV1
9367  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV1)
9368  if MeasRMSV1.get() == 1:
9369  txt = txt + " RMS = " + ' {0:.4f} '.format(SV1)
9370  if MeasUserA.get() == 1:
9371  try:
9372  TempValue = eval(UserAString)
9373  V1String = ' {0:.4f} '.format(TempValue)
9374  except:
9375  V1String = "####"
9376  txt = txt + UserALabel + " = " + V1String
9377  if Xsignal.get() == 2:
9378  txt = "CHA: "
9379  txt = txt + str(CH1IpdvRange) + " mA/div"
9380  elif (Xsignal.get() == 2):
9381  txt = txt + "CHA: "
9382  txt = txt + str(CH1IpdvRange) + " mA/div"
9383  if Xsignal.get() == 2 or YsignalIA.get() == 1:
9384  if MeasDCI1.get() == 1:
9385  V1String = ' {0:.2f} '.format(DCI1)
9386  txt = txt + " AvgI = " + V1String
9387  if AWGAShape.get() == 0: # if this is a DC measurement calc resistance
9388  try:
9389  Resvalue = (DCV1/DCI1)*1000
9390  txt = txt + " Res = " + ' {0:.1f} '.format(Resvalue)
9391  except:
9392  txt = txt + " Res = OverRange"
9393  if MeasMaxI1.get() == 1:
9394  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI1)
9395  if MeasMinI1.get() == 1:
9396  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI1)
9397  if MeasMidI1.get() == 1:
9398  MidI1 = (MaxI1+MinI1)/2
9399  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI1)
9400  if MeasPPI1.get() == 1:
9401  PPI1 = MaxI1-MinI1
9402  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI1)
9403  if MeasRMSI1.get() == 1:
9404  txt = txt + " RMS = " + ' {0:.4f} '.format(SI1)
9405 
9406  x = X0LXY
9407  y = Y0TXY+GRHXY+int(4*FontSize) # 32
9408  XYca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
9409  txt= " "
9410  # Channel B information
9411  if Xsignal.get() == 3 or YsignalVB.get() == 1 or Xsignal.get() == 7:
9412  txt = "CHB: "
9413  txt = txt + str(CH2pdvRange) + " V/div"
9414  if MeasDCV2.get() == 1:
9415  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV2)
9416  if MeasMaxV2.get() == 1:
9417  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV2)
9418  if MeasTopV2.get() == 1:
9419  txt = txt + " Top = " + ' {0:.4f} '.format(VBTop)
9420  if MeasMinV2.get() == 1:
9421  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV2)
9422  if MeasBaseV2.get() == 1:
9423  txt = txt + " Top = " + ' {0:.4f} '.format(VBBase)
9424  if MeasMidV2.get() == 1:
9425  MidV2 = (MaxV2+MinV2)/2
9426  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV2)
9427  if MeasPPV2.get() == 1:
9428  PPV2 = MaxV2-MinV2
9429  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV2)
9430  if MeasRMSV2.get() == 1:
9431  txt = txt + " RMS = " + ' {0:.4f} '.format(SV2)
9432  if MeasUserB.get() == 1:
9433  try:
9434  TempValue = eval(UserBString)
9435  V1String = ' {0:.4f} '.format(TempValue)
9436  except:
9437  V1String = "####"
9438  txt = txt + UserBLabel + " = " + V1String
9439  if Xsignal.get() == 4:
9440  txt = "CHB: "
9441  txt = txt + str(CH2IpdvRange) + " mA/div"
9442  elif Xsignal.get() == 4:
9443  txt = txt + "CHB: "
9444  txt = txt + str(CH2IpdvRange) + " mA/div"
9445  if Xsignal.get() == 4 or YsignalIB.get() == 1:
9446  if MeasDCI2.get() == 1:
9447  V1String = ' {0:.2f} '.format(DCI2)
9448  txt = txt + " AvgI = " + V1String
9449  if AWGBShape.get() == 0: # if this is a DC measurement calc resistance
9450  try:
9451  Resvalue = (DCV2/DCI2)*1000
9452  txt = txt + " Res = " + ' {0:.1f} '.format(Resvalue)
9453  except:
9454  txt = txt + " Res = OverRange"
9455  if MeasMaxI2.get() == 1:
9456  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI2)
9457  if MeasMinI2.get() == 1:
9458  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI2)
9459  if MeasMidI2.get() == 1:
9460  MidI2 = (MaxI2+MinI2)/2
9461  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI2)
9462  if MeasPPI2.get() == 1:
9463  PPI2 = MaxI2-MinI2
9464  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI2)
9465  if MeasRMSI2.get() == 1:
9466  txt = txt + " RMS = " + ' {0:.4f} '.format(SI2)
9467 
9468  x = X0LXY
9469  y = Y0TXY+GRHXY+int(5.5 * FontSize) # 44
9470  XYca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
9471 #
9472 def SetScaleA():
9473  global MarkerScale, CHAlab, CHBlab, CHAIlab, CHBIlab
9474 
9475  if MarkerScale.get() != 1:
9476  MarkerScale.set(1)
9477  CHAlab.config(style="Rtrace1.TButton")
9478  CHBlab.config(style="Strace2.TButton")
9479  CHAIlab.config(style="Strace3.TButton")
9480  CHBIlab.config(style="Strace4.TButton")
9481  else:
9482  MarkerScale.set(0)
9483 #
9484 def SetScaleIA():
9485  global MarkerScale, CHAlab, CHBlab, CHAIlab, CHBIlab
9486 
9487  if MarkerScale.get() != 3:
9488  MarkerScale.set(3)
9489  CHAlab.config(style="Strace1.TButton")
9490  CHBlab.config(style="Strace2.TButton")
9491  CHAIlab.config(style="Rtrace3.TButton")
9492  CHBIlab.config(style="Strace4.TButton")
9493  else:
9494  MarkerScale.set(0)
9495 
9496 def SetScaleB():
9497  global MarkerScale, CHAlab, CHBlab, CHAIlab, CHBIlab
9498 
9499  if MarkerScale.get() != 2:
9500  MarkerScale.set(2)
9501  CHAlab.config(style="Strace1.TButton")
9502  CHBlab.config(style="Rtrace2.TButton")
9503  CHAIlab.config(style="Strace3.TButton")
9504  CHBIlab.config(style="Strace4.TButton")
9505  else:
9506  MarkerScale.set(0)
9507 
9508 def SetScaleIB():
9509  global MarkerScale, CHAlab, CHBlab, CHAIlab, CHBIlab
9510 
9511  if MarkerScale.get() != 3:
9512  MarkerScale.set(4)
9513  CHAlab.config(style="Strace1.TButton")
9514  CHBlab.config(style="Strace2.TButton")
9515  CHAIlab.config(style="Strace3.TButton")
9516  CHBIlab.config(style="Rtrace4.TButton")
9517  else:
9518  MarkerScale.set(0)
9519 #
9520 def SetXYScaleA():
9521  global MarkerXYScale, CHAxylab, CHBxylab
9522 
9523  MarkerXYScale.set(1)
9524  CHAxylab.config(style="Rtrace1.TButton")
9525  CHBxylab.config(style="Strace2.TButton")
9526 
9527 def SetXYScaleB():
9528  global MarkerXYScale, CHAxylab, CHBxylab
9529 
9530  MarkerXYScale.set(2)
9531  CHBxylab.config(style="Rtrace2.TButton")
9532  CHAxylab.config(style="Strace1.TButton")
9533 #
9534 def onCanvasClickRight(event):
9535  global ShowTCur, ShowVCur, TCursor, VCursor, RUNstatus, ca
9536 
9537  TCursor = event.x
9538  VCursor = event.y
9539  if RUNstatus.get() == 0:
9541  ca.bind_all('<MouseWheel>', onCanvasClickScroll)
9542 
9543 def onCanvasClickScroll(event):
9544  global ShowTCur, ShowVCur, TCursor, VCursor, RUNstatus, ca, MWcount
9545  global MeasGateStatus, MeasGateLeft, MeasGateRight, TIMEdiv, GRW
9546 
9547  ShiftKeyDwn = event.state & 1
9548  if event.widget == ca:
9549  if ShowTCur.get() > 0 or ShowVCur.get() > 0: # move cursors if shown
9550  if ShowTCur.get() > 0 and ShiftKeyDwn == 0:
9551  # respond to Linux or Windows wheel event
9552  if event.num == 5 or event.delta == -120:
9553  TCursor -= 1
9554  if event.num == 4 or event.delta == 120:
9555  TCursor += 1
9556  elif ShowVCur.get() > 0 or ShiftKeyDwn == 1:
9557  # respond to Linux or Windows wheel event
9558  if event.num == 5 or event.delta == -120:
9559  VCursor += 1
9560  if event.num == 4 or event.delta == 120:
9561  VCursor -= 1
9562 
9566  else:
9567  if MeasGateStatus.get() == 1:
9568  Tstep = (TIMEdiv / GRW) / 10 # time in mS per pixel
9569  if ShiftKeyDwn == 0:
9570  if event.num == 5 or event.delta == -120:
9571  MeasGateLeft = MeasGateLeft + (-100 * Tstep)
9572  if event.num == 4 or event.delta == 120:
9573  MeasGateLeft = MeasGateLeft + (100 * Tstep)
9574  # MeasGateLeft = MeasGateLeft + (event.delta * Tstep) #+ HoldOff
9575  if ShiftKeyDwn == 1:
9576  if event.num == 5 or event.delta == -120:
9577  MeasGateRight = MeasGateRight + (-100 * Tstep)
9578  if event.num == 4 or event.delta == 120:
9579  MeasGateRight = MeasGateRight + (100 * Tstep)
9580  #MeasGateRight = MeasGateRight + (event.delta * Tstep) #+ HoldOff
9581  try:
9582  onSpinBoxScroll(event) # if cursor are not showing scroll the Horx time base
9583  except:
9584  donothing()
9585  if RUNstatus.get() == 0:
9587 
9588 def onCanvasUpArrow(event):
9589  global ShowVCur, VCursor, YCursor, dBCursor, BdBCursor, RUNstatus, ca, XYca, Freqca, Bodeca
9590 
9591  shift_key = event.state & 1
9592  if event.widget == ca:
9593  if ShowVCur.get() > 0 and shift_key == 0:
9594  VCursor = VCursor - 1
9595  elif ShowVCur.get() > 0 and shift_key == 1:
9596  VCursor = VCursor - 5
9597  if RUNstatus.get() == 0:
9599  try:
9600  if event.widget == XYca:
9601  if ShowYCur.get() > 0 and shift_key == 0:
9602  YCursor = YCursor - 1
9603  elif ShowYCur.get() > 0 and shift_key == 1:
9604  YCursor = YCursor - 5
9605  if RUNstatus.get() == 0:
9606  UpdateXYScreen()
9607  except:
9608  donothing()
9609  try:
9610  if event.widget == Freqca:
9611  if ShowdBCur.get() > 0 and shift_key == 0:
9612  dBCursor = dBCursor - 1
9613  elif ShowdBCur.get() > 0 and shift_key == 1:
9614  dBCursor = dBCursor - 5
9615  if RUNstatus.get() == 0:
9617  except:
9618  donothing()
9619  try:
9620  if event.widget == Bodeca:
9621  if ShowBdBCur.get() > 0 and shift_key == 0:
9622  BdBCursor = BdBCursor - 1
9623  elif ShowBdBCur.get() > 0 and shift_key == 1:
9624  BdBCursor = BdBCursor - 5
9625  if RUNstatus.get() == 0:
9627  except:
9628  donothing()
9629 
9630 def onCanvasDownArrow(event):
9631  global ShowVCur, VCursor, YCursor, dBCursor, BdBCursor, RUNstatus, ca, XYca, Freqca
9632 
9633  shift_key = event.state & 1
9634  if event.widget == ca:
9635  if ShowVCur.get() > 0 and shift_key == 0:
9636  VCursor = VCursor + 1
9637  elif ShowVCur.get() > 0 and shift_key == 1:
9638  VCursor = VCursor + 5
9639  if RUNstatus.get() == 0:
9641  try:
9642  if event.widget == XYca:
9643  if ShowYCur.get() > 0 and shift_key == 0:
9644  YCursor = YCursor + 1
9645  elif ShowYCur.get() > 0 and shift_key == 1:
9646  YCursor = YCursor + 5
9647  if RUNstatus.get() == 0:
9648  UpdateXYScreen()
9649  except:
9650  donothing()
9651  try:
9652  if event.widget == Freqca:
9653  if ShowdBCur.get() > 0 and shift_key == 0:
9654  dBCursor = dBCursor + 1
9655  elif ShowdBCur.get() > 0 and shift_key == 1:
9656  dBCursor = dBCursor + 5
9657  if RUNstatus.get() == 0:
9659  except:
9660  donothing()
9661  try:
9662  if event.widget == Bodeca:
9663  if ShowBdBCur.get() > 0 and shift_key == 0:
9664  BdBCursor = BdBCursor + 1
9665  elif ShowBdBCur.get() > 0 and shift_key == 1:
9666  BdBCursor = BdBCursor + 5
9667  if RUNstatus.get() == 0:
9669  except:
9670  donothing()
9671 
9672 def onCanvasLeftArrow(event):
9673  global ShowTCur, TCursor, XCursor, FCursor, BPCursor, RUNstatus, ca, XYca, Freqca
9674 
9675  shift_key = event.state & 1
9676  if event.widget == ca:
9677  if ShowTCur.get() > 0 and shift_key == 0:
9678  TCursor = TCursor - 1
9679  elif ShowTCur.get() > 0 and shift_key == 1:
9680  TCursor = TCursor - 5
9681  if RUNstatus.get() == 0:
9683  try:
9684  if event.widget == XYca:
9685  if ShowXCur.get() > 0 and shift_key == 0:
9686  XCursor = XCursor - 1
9687  elif ShowXCur.get() > 0 and shift_key == 1:
9688  XCursor = XCursor - 5
9689  if RUNstatus.get() == 0:
9690  UpdateXYScreen()
9691  except:
9692  donothing()
9693  try:
9694  if event.widget == Freqca:
9695  if ShowFCur.get() > 0 and shift_key == 0:
9696  FCursor = FCursor - 1
9697  elif ShowFCur.get() > 0 and shift_key == 1:
9698  FCursor = FCursor - 5
9699  if RUNstatus.get() == 0:
9701  except:
9702  donothing()
9703  try:
9704  if event.widget == Bodeca:
9705  if ShowBPCur.get() > 0 and shift_key == 0:
9706  BPCursor = BPCursor - 1
9707  elif ShowBPCur.get() > 0 and shift_key == 1:
9708  BPCursor = BPCursor - 5
9709  if RUNstatus.get() == 0:
9711  except:
9712  donothing()
9713 
9714 def onCanvasRightArrow(event):
9715  global ShowTCur, TCursor, XCursor, FCursor, BPCursor, RUNstatus, ca, XYca, Freqca
9716 
9717  shift_key = event.state & 1
9718  if event.widget == ca:
9719  if ShowTCur.get() > 0 and shift_key == 0:
9720  TCursor = TCursor + 1
9721  elif ShowTCur.get() > 0 and shift_key == 1:
9722  TCursor = TCursor + 5
9723  if RUNstatus.get() == 0:
9725  try:
9726  if event.widget == XYca:
9727  if ShowXCur.get() > 0 and shift_key == 0:
9728  XCursor = XCursor + 1
9729  elif ShowXCur.get() > 0 and shift_key == 1:
9730  XCursor = XCursor + 5
9731  if RUNstatus.get() == 0:
9732  UpdateXYScreen()
9733  except:
9734  donothing()
9735  try:
9736  if event.widget == Freqca:
9737  if ShowFCur.get() > 0 and shift_key == 0:
9738  FCursor = FCursor + 1
9739  elif ShowFCur.get() > 0 and shift_key == 1:
9740  FCursor = FCursor + 5
9741  if RUNstatus.get() == 0:
9743  except:
9744  donothing()
9745  try:
9746  if event.widget == Bodeca:
9747  if ShowBPCur.get() > 0 and shift_key == 0:
9748  BPCursor = BPCursor + 1
9749  elif ShowBPCur.get() > 0 and shift_key == 1:
9750  BPCursor = BPCursor + 5
9751  if RUNstatus.get() == 0:
9753  except:
9754  donothing()
9755 
9756 def onCanvasSpaceBar(event):
9757  global RUNstatus, ca, XYca, Freqca, Bodeca, IAca
9758 
9759  if event.widget == ca:
9760  if RUNstatus.get() == 0:
9761  BStart()
9762  elif RUNstatus.get() > 0:
9763  BStop()
9764  try:
9765  if event.widget == XYca:
9766  if RUNstatus.get() == 0:
9767  BStart()
9768  elif RUNstatus.get() > 0:
9769  BStop()
9770  except:
9771  donothing()
9772  try:
9773  if event.widget == IAca:
9774  if RUNstatus.get() == 0:
9775  BStart()
9776  elif RUNstatus.get() > 0:
9777  BStop()
9778  except:
9779  donothing()
9780  try:
9781  if event.widget == Freqca:
9782  if RUNstatus.get() == 0:
9783  BStartSA()
9784  elif RUNstatus.get() > 0:
9785  BStopSA()
9786  except:
9787  donothing()
9788  try:
9789  if event.widget == Bodeca:
9790  if RUNstatus.get() == 0:
9791  BStartBP()
9792  elif RUNstatus.get() > 0:
9793  BStopBP()
9794  except:
9795  donothing()
9796 #
9797 def onCanvasClickLeft(event):
9798  global X0L # Left top X value
9799  global Y0T # Left top Y value
9800  global GRW # Screenwidth
9801  global GRH # Screenheight
9802  global FontSize
9803  global ca, MarkerLoc, Mulx, Roll_Mode
9804  global HoldOffentry, Xsignal, Ysignal, COLORgrid, COLORtext
9805  global TMsb, CHAsb, CHBsb, CHAIsb, CHBIsb, MarkerScale
9806  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry
9807  global SAMPLErate, RUNstatus, MarkerNum, PrevV, PrevT
9808  global COLORtrace1, COLORtrace2, MathUnits, MathXUnits, MathYUnits
9809  global CH1pdvRange, CH2pdvRange, CH1IpdvRange, CH2IpdvRange
9810  global CHAOffset, CHAIOffset, CHBOffset, CHBIOffset
9811  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry
9812  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
9813  global MeasGateLeft, MeasGateRight, MeasGateStatus, MeasGateNum, TMsb, SAMPLErate
9814 
9815  try:
9816  HoldOff = float(eval(HoldOffentry.get()))
9817  if HoldOff < 0:
9818  HoldOff = 0
9819  except:
9820  HoldOffentry.delete(0,END)
9821  HoldOffentry.insert(0, HoldOff)
9822  # get time scale
9823  try:
9824  TIMEdiv = float(eval(TMsb.get()))
9825  except:
9826  TIMEdiv = 0.5
9827  TMsb.delete(0,"end")
9828  TMsb.insert(0,TIMEdiv)
9829  # prevent divide by zero error
9830  if TIMEdiv < 0.0002:
9831  TIMEdiv = 0.01
9832  # add markers only if stopped
9833  if (RUNstatus.get() == 0):
9834  MarkerNum = MarkerNum + 1
9835  # get the vertical ranges
9836  try:
9837  CH1pdvRange = float(eval(CHAsb.get()))
9838  except:
9839  CHAsb.delete(0,END)
9840  CHAsb.insert(0, CH1pdvRange)
9841  try:
9842  CH2pdvRange = float(eval(CHBsb.get()))
9843  except:
9844  CHBsb.delete(0,END)
9845  CHBsb.insert(0, CH2pdvRange)
9846  try:
9847  CH1IpdvRange = float(eval(CHAIsb.get()))
9848  except:
9849  CHAIsb.delete(0,END)
9850  CHAIsb.insert(0, CH1IpdvRange)
9851  try:
9852  CH2IpdvRange = float(eval(CHBIsb.get()))
9853  except:
9854  CHBIsb.delete(0,END)
9855  CHBIsb.insert(0, CH2IpdvRange)
9856  # get the vertical offsets
9857  try:
9858  CHAOffset = float(eval(CHAVPosEntry.get()))
9859  except:
9860  CHAVPosEntry.delete(0,END)
9861  CHAVPosEntry.insert(0, CHAOffset)
9862  try:
9863  CHAIOffset = float(eval(CHAIPosEntry.get()))
9864  except:
9865  CHAIPosEntry.delete(0,END)
9866  CHAIPosEntry.insert(0, CHAIOffset)
9867  try:
9868  CHBOffset = float(eval(CHBVPosEntry.get()))
9869  except:
9870  CHBVPosEntry.delete(0,END)
9871  CHBVPosEntry.insert(0, CHBOffset)
9872  try:
9873  CHBIOffset = float(eval(CHBIPosEntry.get()))
9874  except:
9875  CHBIPosEntry.delete(0,END)
9876  CHBIPosEntry.insert(0, CHBIOffset)
9877  # prevent divide by zero error
9878  if CH1pdvRange < 0.001:
9879  CH1pdvRange = 0.001
9880  if CH2pdvRange < 0.001:
9881  CH2pdvRange = 0.001
9882  if CH1IpdvRange < 1.0:
9883  CH1IpdvRange = 1.0
9884  if CH2IpdvRange < 1.0:
9885  CH2IpdvRange = 1.0
9886 #
9887  if MuxScreenStatus.get() == 1: # if using analog Mux set up axis controls
9888  try:
9889  CHMApdvRange = float(eval(CHB_Asb.get()))
9890  except:
9891  CHB_Asb.delete(0,END)
9892  CHB_Asb.insert(0, CHMApdvRange)
9893  try:
9894  CHMBpdvRange = float(eval(CHB_Bsb.get()))
9895  except:
9896  CHB_Bsb.delete(0,END)
9897  CHB_Bsb.insert(0, CHMBpdvRange)
9898  try:
9899  CHMCpdvRange = float(eval(CHB_Csb.get()))
9900  except:
9901  CHB_Csb.delete(0,END)
9902  CHB_Csb.insert(0, CHMCpdvRange)
9903  try:
9904  CHMDpdvRange = float(eval(CHB_Dsb.get()))
9905  except:
9906  CHB_Dsb.delete(0,END)
9907  CHB_Dsb.insert(0, CHMDpdvRange)
9908  YconvMA = float(GRH/10.0) / CHMApdvRange
9909  YconvMB = float(GRH/10.0) / CHMBpdvRange
9910  YconvMC = float(GRH/10.0) / CHMCpdvRange
9911  YconvMD = float(GRH/10.0) / CHMDpdvRange
9912  try:
9913  CHBAOffset = float(eval(CHB_APosEntry.get()))
9914  except:
9915  CHB_APosEntry.delete(0,END)
9916  CHB_APosEntry.insert(0, CHBAOffset)
9917  try:
9918  CHBBOffset = float(eval(CHB_BPosEntry.get()))
9919  except:
9920  CHB_BPosEntry.delete(0,END)
9921  CHB_BPosEntry.insert(0, CHBBOffset)
9922  try:
9923  CHBCOffset = float(eval(CHB_CPosEntry.get()))
9924  except:
9925  CHB_CPosEntry.delete(0,END)
9926  CHB_CPosEntry.insert(0, CHBCOffset)
9927  try:
9928  CHBDOffset = float(eval(CHB_DPosEntry.get()))
9929  except:
9930  CHB_DPosEntry.delete(0,END)
9931  CHB_DPosEntry.insert(0, CHBDOffset)
9932  Yoffset1 = CHAOffset
9933  if MarkerScale.get() == 1:
9934  Yconv1 = float(GRH/10.0) / CH1pdvRange
9935  Yoffset1 = CHAOffset
9936  COLORmarker = COLORtrace1
9937  Units = " V"
9938  elif MarkerScale.get() == 2:
9939  Yconv1 = float(GRH/10.0) / CH2pdvRange
9940  Yoffset1 = CHBOffset
9941  COLORmarker = COLORtrace2
9942  Units = " V"
9943  elif MarkerScale.get() == 3:
9944  Yconv1 = float(GRH/10.0) / CH1IpdvRange
9945  Yoffset1 = CHAIOffset
9946  COLORmarker = COLORtrace3
9947  Units = " mA"
9948  elif MarkerScale.get() == 4:
9949  Yconv1 = float(GRH/10.0) / CH2IpdvRange
9950  Yoffset1 = CHBIOffset
9951  COLORmarker = COLORtrace4
9952  Units = " mA"
9953  # Aanalog Mux settings
9954  elif MarkerScale.get() == 5:
9955  Yconv1 = float(GRH/10.0) / CHMApdvRange
9956  Yoffset1 = CHBAOffset
9957  COLORmarker = COLORtrace2
9958  Units = " V"
9959  elif MarkerScale.get() == 6:
9960  Yconv1 = float(GRH/10.0) / CHMBpdvRange
9961  Yoffset1 = CHBBOffset
9962  COLORmarker = COLORtrace6
9963  Units = " V"
9964  elif MarkerScale.get() == 7:
9965  Yconv1 = float(GRH/10.0) / CHMCpdvRange
9966  Yoffset1 = CHBCOffset
9967  COLORmarker = COLORtrace7
9968  Units = " V"
9969  elif MarkerScale.get() == 8:
9970  Yconv1 = float(GRH/10.0) / CHMDpdvRange
9971  Yoffset1 = CHBDOffset
9972  COLORmarker = COLORtrace4
9973  Units = " V"
9974  else:
9975  Yconv1 = float(GRH/10.0) / CH1pdvRange
9976  Yoffset1 = CHAOffset
9977  COLORmarker = COLORtrace1
9978  Units = " V"
9979  #
9980  c1 = GRH / 2.0 + Y0T # fixed correction channel A
9981  xc1 = GRW / 2.0 + X0L
9982  c2 = GRH / 2.0 + Y0T # fixed correction channel B
9983  # draw X at marker point and number
9984  ca.create_line(event.x-4, event.y-4,event.x+4, event.y+5, fill=COLORtext)
9985  ca.create_line(event.x+4, event.y-4,event.x-4, event.y+5, fill=COLORtext)
9986  # DISsamples = (10.0 * TIMEdiv) # grid width in time
9987  Tstep = (10.0 * TIMEdiv) / GRW # time in mS per pixel
9988  Tpoint = ((event.x-X0L) * Tstep) + HoldOff
9989  #
9990  Tpoint = Tpoint/Mulx
9991  if Tpoint >= 1000:
9992  axis_value = Tpoint / 1000.0
9993  TString = ' {0:.2f} '.format(axis_value) + " S "
9994  if Tpoint < 1000 and Tpoint >= 1:
9995  axis_value = Tpoint
9996  TString = ' {0:.2f} '.format(axis_value) + " mS "
9997  if Tpoint < 1:
9998  axis_value = Tpoint * 1000.0
9999  TString = ' {0:.2f} '.format(axis_value) + " uS "
10000  # TString = ' {0:.2f} '.format(Tpoint)
10001  yvolts = ((event.y-c1)/Yconv1) - Yoffset1
10002  if MarkerScale.get() == 1 or MarkerScale.get() == 2:
10003  V1String = ' {0:.3f} '.format(-yvolts)
10004  else:
10005  V1String = ' {0:.1f} '.format(-yvolts)
10006  V_label = str(MarkerNum) + " " + TString + V1String
10007  V_label = V_label + Units
10008  if MarkerNum > 1:
10009  if MarkerScale.get() == 1 or MarkerScale.get() == 2:
10010  DeltaV = ' {0:.3f} '.format(PrevV-yvolts)
10011  else:
10012  DeltaV = ' {0:.1f} '.format(PrevV-yvolts)
10013  if Roll_Mode.get() == 0: # should be same as First_Slow_sweep == 0
10014  DT = (Tpoint-PrevT)
10015  if Tpoint >= 1000:
10016  axis_value = DT / 1000.0
10017  DeltaT = ' {0:.2f} '.format(axis_value) + " S "
10018  if Tpoint < 1000 and Tpoint >= 1:
10019  axis_value = DT
10020  DeltaT = ' {0:.2f} '.format(axis_value) + " mS "
10021  if Tpoint < 1:
10022  axis_value = DT * 1000.0
10023  DeltaT = ' {0:.2f} '.format(axis_value) + " uS "
10024  # DeltaT = ' {0:.3f} '.format(Tpoint-PrevT)
10025  DFreq = ' {0:.3f} '.format(1.0/(Tpoint-PrevT))
10026  V_label = V_label + " Delta " + DeltaT + DeltaV
10027  V_label = V_label + Units
10028  V_label = V_label + ", Freq " + DFreq + " KHz"
10029  else:
10030  V_label = V_label + " Delta " + DeltaV + Units
10031  # place in upper left unless specified otherwise
10032  TxScale = FontSize + 2
10033  x = X0L + 5
10034  y = Y0T + 3 + (MarkerNum*TxScale)
10035  Justify = 'w'
10036  if MarkerLoc == 'UR' or MarkerLoc == 'ur':
10037  x = X0L + GRW - 5
10038  y = Y0T + 3 + (MarkerNum*TxScale)
10039  Justify = 'e'
10040  if MarkerLoc == 'LL' or MarkerLoc == 'll':
10041  x = X0L + 5
10042  y = Y0T + GRH + 3 - (MarkerNum*TxScale)
10043  Justify = 'w'
10044  if MarkerLoc == 'LR' or MarkerLoc == 'lr':
10045  x = X0L + GRW - 5
10046  y = Y0T + GRH + 3 - (MarkerNum*TxScale)
10047  Justify = 'e'
10048  ca.create_text(event.x+4, event.y, text=str(MarkerNum), fill=COLORtext, anchor=Justify, font=("arial", FontSize ))
10049  ca.create_text(x, y, text=V_label, fill=COLORmarker, anchor=Justify, font=("arial", FontSize ))
10050  PrevV = yvolts
10051  PrevT = Tpoint
10052  else:
10053  if MeasGateStatus.get() == 1:
10054  #DISsamples = (10.0 * TIMEdiv) # grid width in time
10055  Tstep = (10.0 * TIMEdiv) / GRW # time in mS per pixel
10056  if MeasGateNum == 0:
10057  MeasGateLeft = ((event.x-X0L) * Tstep) #+ HoldOff
10058  MeasGateNum = 1
10059  else:
10060  MeasGateRight = ((event.x-X0L) * Tstep) #+ HoldOff
10061  MeasGateNum = 0
10062  LeftGate = X0L + MeasGateLeft / Tstep
10063  RightGate = X0L + MeasGateRight / Tstep
10064  ca.create_line(LeftGate, Y0T, LeftGate, Y0T+GRH, fill=COLORtext)
10065  ca.create_line(RightGate, Y0T, RightGate, Y0T+GRH, fill=COLORtext)
10066 
10067 #
10068 def onCanvasOne(event):
10069  global ShowC1_V
10070 
10071  if ShowC1_V.get() == 0:
10072  ShowC1_V.set(1)
10073  else:
10074  ShowC1_V.set(0)
10075 #
10076 def onCanvasTwo(event):
10077  global ShowC2_V
10078 
10079  if ShowC2_V.get() == 0:
10080  ShowC2_V.set(1)
10081  else:
10082  ShowC2_V.set(0)
10083 #
10084 def onCanvasThree(event):
10085  global ShowC1_I
10086 
10087  if ShowC1_I.get() == 0:
10088  ShowC1_I.set(1)
10089  else:
10090  ShowC1_I.set(0)
10091 #
10092 def onCanvasFour(event):
10093  global ShowC2_I
10094 
10095  if ShowC2_I.get() == 0:
10096  ShowC2_I.set(1)
10097  else:
10098  ShowC2_I.set(0)
10099 #
10100 def onCanvasFive(event):
10101  global MathTrace
10102 
10103  MathTrace.set(1)
10104 #
10105 def onCanvasSix(event):
10106  global MathTrace
10107 
10108  MathTrace.set(2)
10109 #
10110 def onCanvasSeven(event):
10111  global MathTrace
10112 
10113  MathTrace.set(3)
10114 #
10115 def onCanvasEight(event):
10116  global MathTrace
10117 
10118  MathTrace.set(10)
10119 #
10120 def onCanvasNine(event):
10121  global MathTrace
10122 
10123  MathTrace.set(12)
10124 #
10125 def onCanvasZero(event):
10126  global MathTrace
10127 
10128  MathTrace.set(0)
10129 #
10130 def onCanvasTrising(event):
10131  global TgEdge
10132 
10133  TgEdge.set(0)
10134 #
10135 def onCanvasTfalling(event):
10136  global TgEdge
10137 
10138  TgEdge.set(1)
10139 #
10140 def onCanvasSnap(event):
10141 
10142  BSnapShot()
10143 #
10144 def onCanvasAverage(event):
10145  global TRACEmodeTime
10146 
10147  if TRACEmodeTime.get() == 0:
10148  TRACEmodeTime.set(1)
10149  else:
10150  TRACEmodeTime.set(0)
10151 #
10152 def onCanvasShowTcur(event):
10153  global ShowTCur
10154 
10155  if ShowTCur.get() == 0:
10156  ShowTCur.set(1)
10157  else:
10158  ShowTCur.set(0)
10159 #
10160 def onCanvasShowVcur(event):
10161  global ShowVCur
10162 
10163  if ShowVCur.get() == 0:
10164  ShowVCur.set(1)
10165  else:
10166  ShowVCur.set(0)
10167 #
10168 def onCanvasXYRightClick(event):
10169  global ShowXCur, ShowYCur, XCursor, YCursor, RUNstatus, XYca
10170 
10171  XCursor = event.x
10172  YCursor = event.y
10173  if RUNstatus.get() == 0:
10174  UpdateXYScreen()
10175  XYca.bind_all('<MouseWheel>', onCanvasXYScrollClick)
10176 #
10177 def onCanvasXYScrollClick(event):
10178  global ShowXCur, ShowYCur, XCursor, YCursor, RUNstatus
10179  if event.widget == XYca:
10180  if ShowXCur.get() > 0 or ShowYCur.get() > 0: # move cursors if shown
10181  ShiftKeyDwn = event.state & 1
10182  if ShowXCur.get() > 0 and ShiftKeyDwn == 0:
10183  # respond to Linux or Windows wheel event
10184  if event.num == 5 or event.delta == -120:
10185  XCursor -= 1
10186  if event.num == 4 or event.delta == 120:
10187  XCursor += 1
10188  # XCursor = XCursor + event.delta/100
10189  elif ShowYCur.get() > 0 or ShiftKeyDwn == 1:
10190  # respond to Linux or Windows wheel event
10191  if event.num == 5 or event.delta == -120:
10192  YCursor += 1
10193  if event.num == 4 or event.delta == 120:
10194  YCursor -= 1
10195  #YCursor = YCursor - event.delta/100
10196  if RUNstatus.get() == 0:
10197  UpdateXYScreen()
10198 #
10199 def onCanvasXYLeftClick(event):
10200  global X0LXY # Left top X value
10201  global Y0TXY # Left top Y value
10202  global GRWXY # Screenwidth
10203  global GRHXY # Screenheight
10204  global FontSize
10205  global XYca
10206  global HoldOffentry, Xsignal, Ysignal, COLORgrid, COLORtext
10207  global TMsb, CHAsbxy, CHBsbxy, CHAIsbxy, CHBIsbxy, MarkerScale
10208  global CHAVPosEntryxy, CHAIPosEntryxy, CHBVPosEntryxy, CHBIPosEntryxy
10209  global SAMPLErate, RUNstatus, MarkerNum, PrevX, PrevY
10210  global COLORtrace1, COLORtrace2, MathUnits, MathXUnits, MathYUnits
10211  global CH1pdvRange, CH2pdvRange, CH1IpdvRange, CH2IpdvRange
10212  global CHAOffset, CHAIOffset, CHBOffset, CHBIOffset
10213  # add markers only if stopped
10214  #
10215  if (RUNstatus.get() == 0):
10216  MarkerNum = MarkerNum + 1
10217  try:
10218  CH1pdvRange = float(eval(CHAsbxy.get()))
10219  except:
10220  CHAsbxy.delete(0,END)
10221  CHAsbxy.insert(0, CH1pdvRange)
10222  try:
10223  CH2pdvRange = float(eval(CHBsbxy.get()))
10224  except:
10225  CHBsb.delete(0,END)
10226  CHBsb.insert(0, CH2pdvRange)
10227  try:
10228  CH1IpdvRange = float(eval(CHAIsbxy.get()))
10229  except:
10230  CHAIsbxy.delete(0,END)
10231  CHAIsbxy.insert(0, CH1IpdvRange)
10232  try:
10233  CH2IpdvRange = float(eval(CHBIsbxy.get()))
10234  except:
10235  CHBIsbxy.delete(0,END)
10236  CHBIsbxy.insert(0, CH2IpdvRange)
10237  # get the vertical offsets
10238  try:
10239  CHAOffset = float(eval(CHAVPosEntryxy.get()))
10240  except:
10241  CHAVPosEntryxy.delete(0,END)
10242  CHAVPosEntryxy.insert(0, CHAOffset)
10243  try:
10244  CHAIOffset = float(eval(CHAIPosEntryxy.get()))
10245  except:
10246  CHAIPosEntryxy.delete(0,END)
10247  CHAIPosEntryxy.insert(0, CHAIOffset)
10248  try:
10249  CHBOffset = float(eval(CHBVPosEntryxy.get()))
10250  except:
10251  CHBVPosEntryxy.delete(0,END)
10252  CHBVPosEntryxy.insert(0, CHBOffset)
10253  try:
10254  CHBIOffset = float(eval(CHBIPosEntryxy.get()))
10255  except:
10256  CHBIPosEntryxy.delete(0,END)
10257  CHBIPosEntryxy.insert(0, CHBIOffset)
10258  # prevent divide by zero error
10259  if CH1pdvRange < 0.001:
10260  CH1pdvRange = 0.001
10261  if CH2pdvRange < 0.001:
10262  CH2pdvRange = 0.001
10263  if CH1IpdvRange < 1.0:
10264  CH1IpdvRange = 1.0
10265  if CH2IpdvRange < 1.0:
10266  CH2IpdvRange = 1.0
10267  try:
10268  HoldOff = float(eval(HoldOffentry.get()))
10269  if HoldOff < 0:
10270  HoldOff = 0
10271  except:
10272  HoldOffentry.delete(0,END)
10273  HoldOffentry.insert(0, HoldOff)
10274  #
10275  Yconv1 = float(GRHXY/10) / CH1pdvRange # Conversion factors from samples to screen points
10276  Xconv1 = float(GRWXY/10) / CH1pdvRange
10277  Yconv2 = float(GRHXY/10) / CH2pdvRange
10278  Xconv2 = float(GRWXY/10) / CH2pdvRange
10279  YIconv1 = float(GRHXY/10) / CH1IpdvRange
10280  YIconv2 = float(GRHXY/10) / CH2IpdvRange
10281  COLORmarker = COLORtext
10282  Yoffset1 = CHAOffset
10283  c1 = GRHXY / 2 + Y0TXY # fixed correction channel A
10284  xc1 = GRWXY / 2 + X0LXY
10285  c2 = GRHXY / 2 + Y0TXY # fixed correction channel B
10286  # draw X at marker point and number
10287  XYca.create_line(event.x-4, event.y-4,event.x+4, event.y+5, fill=COLORtext)
10288  XYca.create_line(event.x+4, event.y-4,event.x-4, event.y+5, fill=COLORtext)
10289  XYca.create_text(event.x+4, event.y, text=str(MarkerNum), fill=COLORtext, anchor="w", font=("arial", FontSize ))
10290  V_label = str(MarkerNum) + " "
10291  x = X0LXY + 5
10292  y = Y0TXY + 3 + (MarkerNum*10)
10293  xvolts = ((xc1-event.x)/Xconv1) - CHAOffset # preset the variable
10294  if (Xsignal.get()==1 or Xsignal.get()==5) and (Ysignal.get()==3 or Ysignal.get()==5):
10295  yvolts = ((event.y-c2)/Yconv2) - CHBOffset
10296  xvolts = ((xc1-event.x)/Xconv1) - CHAOffset
10297  VyString = ' {0:.3f} '.format(-yvolts)
10298  VxString = ' {0:.3f} '.format(-xvolts)
10299  V_label = V_label + VxString + " V, " + VyString + " V"
10300  if MarkerNum > 1:
10301  DeltaY = ' {0:.3f} '.format(PrevY-yvolts)
10302  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
10303  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " V"
10304  PrevY = yvolts
10305  elif (Xsignal.get()==3 or Xsignal.get()==5) and (Ysignal.get()==1 or Ysignal.get()==5):
10306  yvolts = ((event.y-c1)/Yconv1) - CHAOffset
10307  xvolts = ((xc1-event.x)/Xconv2) - CHBOffset
10308  VyString = ' {0:.3f} '.format(-yvolts)
10309  VxString = ' {0:.3f} '.format(-xvolts)
10310  V_label = V_label + VxString + " V, " + VyString + " V"
10311  if MarkerNum > 1:
10312  DeltaY = ' {0:.3f} '.format(PrevY-yvolts)
10313  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
10314  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " V"
10315  PrevY = yvolts
10316  elif (Xsignal.get()==1 or Xsignal.get()==5) and (Ysignal.get()==2 or Ysignal.get()==5):
10317  xvolts = ((xc1-event.x)/Xconv1) - CHAOffset
10318  ymA = ((event.y-c2)/YIconv1) - CHAIOffset
10319  VxString = ' {0:.3f} '.format(-xvolts)
10320  VyString = ' {0:.1f} '.format(-ymA)
10321  V_label = V_label + VxString + " V, " + VyString + " mA"
10322  if MarkerNum > 1:
10323  DeltaY = ' {0:.2f} '.format(PrevY-ymA)
10324  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
10325  DeltaR = ' {0:.3f} '.format(((PrevX-xvolts)/(PrevY-ymA))*1000)
10326  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " mA"
10327  V_label = V_label + ", dV/dI " + DeltaR
10328  PrevY = ymA
10329  elif (Xsignal.get()==3 or Xsignal.get()==5) and (Ysignal.get()==4 or Ysignal.get()==5):
10330  xvolts = ((xc1-event.x)/Xconv2) - CHBOffset
10331  ymA = ((event.y-c2)/YIconv2) - CHBIOffset
10332  VxString = ' {0:.3f} '.format(-xvolts)
10333  VyString = ' {0:.1f} '.format(-ymA)
10334  V_label = V_label + VxString + " V, " + VyString + " mA"
10335  if MarkerNum > 1:
10336  DeltaY = ' {0:.2f} '.format(PrevY-ymA)
10337  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
10338  DeltaR = ' {0:.3f} '.format(((PrevX-xvolts)/(PrevY-ymA))*1000)
10339  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " mA"
10340  V_label = V_label + ", dV/dI " + DeltaR
10341  PrevY = ymA
10342  elif (Xsignal.get()==3 or Xsignal.get()==5) and (Ysignal.get()==2 or Ysignal.get()==5):
10343  xvolts = ((xc1-event.x)/Xconv2) - CHBOffset
10344  ymA = ((event.y-c2)/YIconv1) - CHAIOffset
10345  VxString = ' {0:.3f} '.format(-xvolts)
10346  VyString = ' {0:.1f} '.format(-ymA)
10347  V_label = V_label + VxString + " V, " + VyString + " mA"
10348  if MarkerNum > 1:
10349  DeltaY = ' {0:.2f} '.format(PrevY-ymA)
10350  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
10351  DeltaR = ' {0:.3f} '.format(((PrevX-xvolts)/(PrevY-ymA))*1000)
10352  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " mA"
10353  V_label = V_label + ", dV/dI " + DeltaR
10354  PrevY = ymA
10355  elif (Xsignal.get()==1 or Xsignal.get()==5) and (Ysignal.get()==4 or Ysignal.get()==5):
10356  xvolts = ((xc1-event.x)/Xconv1) - CHAOffset
10357  ymA = ((event.y-c2)/YIconv2) - CHBIOffset
10358  VxString = ' {0:.3f} '.format(-xvolts)
10359  VyString = ' {0:.1f} '.format(-ymA)
10360  V_label = V_label + VxString + " V, " + VyString + " mA"
10361  if MarkerNum > 1:
10362  DeltaY = ' {0:.2f} '.format(PrevY-ymA)
10363  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
10364  DeltaR = ' {0:.3f} '.format(((PrevX-xvolts)/(PrevY-ymA))*1000)
10365  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " mA"
10366  V_label = V_label + ", dV/dI " + DeltaR
10367  PrevY = ymA
10368  XYca.create_text(x, y, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
10369  PrevX = xvolts
10370 #
10371 # Some DSP functions
10372 #
10373 # Generate Time-series From Half-spectrum code block
10374 # takes: a desired noise spectral density array (freq)
10375 # the sample rate of the time series (fs),
10376 # returns a time series of voltage samples that can be sent to the AWG
10377 #
10378 # DC in first element.
10379 # Output length is 2x input length
10380 def time_points_from_freq(freq, fs=1, density=False):
10381  N=len(freq)
10382  rnd_ph_pos = (numpy.ones(N-1, dtype=numpy.complex)*
10383  numpy.exp(1j*numpy.random.uniform
10384  (0.0,2.0*numpy.pi, N-1)))
10385  rnd_ph_neg = numpy.flip(numpy.conjugate(rnd_ph_pos))
10386  rnd_ph_full = numpy.concatenate(([1],rnd_ph_pos,[1], rnd_ph_neg))
10387  r_s_full = numpy.concatenate((freq, numpy.roll(numpy.flip(freq), 1)))
10388  r_spectrum_rnd_ph = r_s_full * rnd_ph_full
10389  r_time_full = numpy.fft.ifft(r_spectrum_rnd_ph)
10390 # print("RMS imaginary component: ",
10391 # np.std(np.imag(r_time_full)),
10392 # " Should be close to nothing")
10393  if (density == True):
10394  #Note that this N is "predivided" by 2
10395  r_time_full *= N*numpy.sqrt(fs/(N))
10396  return(numpy.real(r_time_full))
10397 #
10398 def TimeSeriesNoise(n, Fsample, mag, b=4):
10399  # Build Noise Time-series
10400  # n = number of Freq Bins
10401  # b = number of noise bands
10402  # Fsample is Sample Rate
10403  # generates four "bands" of mag V/rootHz noise
10404  mag = mag * 0.707106 # scale by 1/sqrt 2 for RMS
10405  width = int(n/(4 * b))
10406  i = 1
10407  aband = numpy.ones(width)
10408  zband = numpy.zeros(width)
10409  bands = numpy.concatenate((aband, zband))
10410  while i < b:
10411  bands = numpy.concatenate((bands, aband, zband))
10412  i = i + 1
10413  bands = bands*mag
10414  bands[0] = 0.0 # Set DC bin content to zero
10415  return time_points_from_freq(bands, fs=Fsample, density=True)
10416 #
10417 # Generate Time samples for single frequency Bin
10418 # Uses IFFT
10419 #
10420 def TimeSeriesSingleTone(n, BinNum, Fsample, mag):
10421  # Build Single tone Time-series
10422  # n = number of Freq Bins
10423  # BinNum = FFT Bin number
10424  # Fsample is Sample Rate
10425  # mag is tone amplitude
10426  bands = numpy.zeros(n)
10427  bands[BinNum] = 1
10428  bands = bands * (mag/2.0)
10429  return time_points_from_freq(bands, fs=Fsample, density=True)
10430 #
10431 def PinkNoise(N, mag):
10432  # Pink noise.
10433  # Pink noise has equal power in bands that are proportionally wide.
10434  # Power spectral density decreases with 3 dB per octave.
10435  # N Length of sample array, mag magnitude scaling factor
10436 
10437  x = numpy.random.normal(0.0, 1, N).astype(numpy.float32) # white Noise
10438  X = numpy.fft.rfft(x) / N
10439  S = numpy.sqrt(numpy.arange(X.size)+1.0) # +1 to avoid divide by zero
10440  y = numpy.fft.irfft(X/S).real[:N] # extremely tiny value 1e-9 without normalization
10441  z = numpy.ndarray = mag
10442  y = y * numpy.sqrt((numpy.abs(z)**2).mean() / (numpy.abs(y)**2).mean())
10443 
10444  return y
10445 #
10446 def BlueNoise(N, mag):
10447  # Blue noise.
10448  # Power increases with 6 dB per octave.
10449  # Power spectral density increases with 3 dB per octave.
10450  # N Length of sample array, mag magnitude scaling factor
10451 
10452  # x = numpy.random.randn(N).astype(numpy.float32) # white Noise
10453  x = numpy.random.normal(0.0, 1, N).astype(numpy.float32) # white Noise
10454  X = numpy.fft.rfft(x) / N
10455  S = numpy.sqrt(numpy.arange(X.size)) # Filter
10456  y = numpy.fft.irfft(X*S).real[:N]
10457  z = numpy.ndarray = mag
10458  y = y * numpy.sqrt((numpy.abs(z)**2).mean() / (numpy.abs(y)**2).mean())
10459 
10460  return y
10461 #
10462 def BrownNoise(N, mag):
10463  # Brown noise.
10464  # Power decreases with -3 dB per octave.
10465  # Power spectral density decreases with 6 dB per octave.
10466  # N Length of sample array, mag magnitude scaling factor
10467 
10468  # x = numpy.random.randn(N).astype(numpy.float32) # white Noise
10469  x = numpy.random.normal(0.0, 1, N).astype(numpy.float32) # white Noise
10470  X = numpy.fft.rfft(x) / N
10471  S = numpy.arange(X.size)+1 # Filter
10472  y = numpy.fft.irfft(X/S).real[:N]
10473  z = numpy.ndarray = mag
10474  y = y * numpy.sqrt((numpy.abs(z)**2).mean() / (numpy.abs(y)**2).mean())
10475 
10476  return y
10477 #
10478 def VioletNoise(N, mag):
10479  # Violet noise.
10480  # Power increases with +9 dB per octave.
10481  # Power density increases with +6 dB per octave.
10482  # N Length of sample array, mag magnitude scaling factor
10483 
10484  # x = numpy.random.randn(N).astype(numpy.float32) # white Noise
10485  x = numpy.random.normal(0.0, 1, N).astype(numpy.float32) # white Noise
10486  X = numpy.fft.rfft(x) / N
10487  S = numpy.arange(X.size) # Filter
10488  y = numpy.fft.irfft(X*S).real[0:N]
10489  z = numpy.ndarray = mag
10490  y = y * numpy.sqrt((numpy.abs(z)**2).mean() / (numpy.abs(y)**2).mean())
10491 
10492  return y
10493 #
10494 def SchroederPhase(Length, NrTones, Ampl):
10495  # Generate a Schroeder Phase (Chirp) of Length samples and having NrTones
10496  OutArray = []
10497  OutArray = Ampl*numpy.cos(numpy.linspace(0, 2*numpy.pi, Length)) # the fundamental
10498  k = 2
10499  while k <= NrTones:
10500  # Add all harmonics up to NrTones
10501  Harmonic = Ampl*numpy.cos(numpy.linspace(0, k*2*numpy.pi, Length)+(numpy.pi*k*k/NrTones))
10502  OutArray = OutArray + Harmonic
10503  k = k + 1
10504  OutArray = OutArray + 2.5 # Center wavefrom on 2.5 V
10505  return(OutArray)
10506 #
10507 def Wrap(InArray, WrFactor):
10508  # Build new array by skipping WrFactor samples and wrapping back around
10509  # [1,2,3,4,5,6} becomes [1,3,5,2,4,6]
10510  # effectively multiplies the frequency content by WrFactor
10511  OutArray = []
10512  OutArray = numpy.array(OutArray)
10513  InArray = numpy.array(InArray)
10514  EndIndex = len(InArray)
10515  StartIndex = 0
10516  while StartIndex < WrFactor:
10517  OutArray = numpy.concatenate((OutArray, InArray[StartIndex:EndIndex:WrFactor]), axis=0)
10518  StartIndex = StartIndex + 1
10519  return OutArray
10520 #
10521 def UnWrap(InArray, WrFactor):
10522  # Build new array by splitting arrray into WrFactor sections and interleaving samples from each section
10523  # [1,2,3,4,5,6} becomes [1,4,2,5,3,6]
10524  # effectively divided the frequency content by WrFactor
10525  OutArray = []
10526  InArray = numpy.array(InArray)
10527  EndIndex = int(len(InArray)/WrFactor)
10528  StartIndex = 0
10529  while StartIndex < EndIndex:
10530  LoopIndex = 0
10531  while LoopIndex < WrFactor:
10532  OutArray.append(InArray[StartIndex+LoopIndex])
10533  LoopIndex = LoopIndex + 1
10534  StartIndex = StartIndex + 1
10535  OutArray = numpy.array(OutArray)
10536  return OutArray
10537 #
10538 def Write_WAV(data, repeat, filename):
10539  global SAMPLErate
10540  # write data array to mono .wav file 100KSPS
10541  # copy buffer repeat times in output file
10542  # Use : Write_WAV(VBuffB, 2, "write_wave_1.wav")
10543  wavfile = wave.open(filename, "w")
10544  nchannels = 1
10545  sampwidth = 2
10546  framerate = SAMPLErate
10547  amplitude = 32766
10548  nframes = len(data)
10549  comptype = "NONE"
10550  compname = "not compressed"
10551  wavfile.setparams((nchannels,
10552  sampwidth,
10553  framerate,
10554  nframes,
10555  comptype,
10556  compname))
10557  # Normalize data
10558  ArrN = numpy.array(data)
10559  ArrN /= numpy.max(numpy.abs(data))
10560  frames = []
10561  for s in ArrN:
10562  mul = int(s * amplitude)
10563  # print "s: %f mul: %d" % (s, mul)
10564  frames.append(struct.pack('h', mul))
10565  print( len(frames))
10566  frames = ''.join(frames)
10567  print( len(frames))
10568  for x in xrange(0, repeat):
10569  print( x )
10570  wavfile.writeframes(frames)
10571  wavfile.close()
10572 
10573 # =========== Awg functions ==================
10574 def BAWGAAmpl(temp):
10575  global AWGAAmplEntry, AWGAAmplvalue, AWGAMode, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10576  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10577 
10578  try:
10579  AWGAAmplvalue = float(eval(AWGAAmplEntry.get()))
10580  except:
10581  AWGAAmplEntry.delete(0,"end")
10582  AWGAAmplEntry.insert(0, AWGAAmplvalue)
10583  #
10584  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode
10585  if AWGAMode.get() == 0: # Source Voltage measure current mode
10586  if AWGAAmplvalue > 5.00:
10587  AWGAAmplvalue = 5.00
10588  AWGAAmplEntry.delete(0,"end")
10589  AWGAAmplEntry.insert(0, AWGAAmplvalue)
10590  if AWGAAmplvalue < 0.00:
10591  AWGAAmplvalue = 0.00
10592  AWGAAmplEntry.delete(0,"end")
10593  AWGAAmplEntry.insert(0, AWGAAmplvalue)
10594  elif AWG_Amp_Mode.get() == 1: # 1 = Amp/Offset
10595  if AWGAMode.get() == 0: # Source Voltage measure current mode
10596  if AWGAAmplvalue > (2.5 / AWGA_Ext_Gain.get()):
10597  AWGAAmplvalue = 2.5 / AWGA_Ext_Gain.get()
10598  AWGAAmplEntry.delete(0,"end")
10599  AWGAAmplEntry.insert(0, AWGAAmplvalue)
10600  if AWGAAmplvalue < (-2.50 / AWGA_Ext_Gain.get()):
10601  AWGAAmplvalue = -2.50 / AWGA_Ext_Gain.get()
10602  AWGAAmplEntry.delete(0,"end")
10603  AWGAAmplEntry.insert(0, AWGAAmplvalue)
10604  if AWGAMode.get() == 1: # Source current measure voltage mode
10605  if AWGAAmplvalue > 200.00:
10606  AWGAAmplvalue = 200.00
10607  AWGAAmplEntry.delete(0,"end")
10608  AWGAAmplEntry.insert(0, AWGAAmplvalue)
10609  if AWGAAmplvalue < -200.00:
10610  AWGAAmplvalue = -200.00
10611  AWGAAmplEntry.delete(0,"end")
10612  AWGAAmplEntry.insert(0, AWGAAmplvalue)
10613 #
10614 def BAWGAOffset(temp):
10615  global AWGAOffsetEntry, AWGAOffsetvalue, AWGAMode, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10616  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10617 
10618  try:
10619  AWGAOffsetvalue = float(eval(AWGAOffsetEntry.get()))
10620  except:
10621  AWGAOffsetEntry.delete(0,"end")
10622  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
10623  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode
10624  if AWGAMode.get() == 0: # Source Voltage measure current mode
10625  if AWGAOffsetvalue > 5.00:
10626  AWGAOffsetvalue = 5.00
10627  AWGAOffsetEntry.delete(0,"end")
10628  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
10629  if AWGAOffsetvalue < 0.00:
10630  AWGAOffsetvalue = 0.00
10631  AWGAOffsetEntry.delete(0,"end")
10632  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
10633  elif AWG_Amp_Mode.get() == 1: # 1 = Amp/Offset
10634  if AWGAOffsetvalue > (2.50-AWGA_Ext_Offset.get()):
10635  AWGAOffsetvalue = 2.50-AWGA_Ext_Offset.get()
10636  AWGAOffsetEntry.delete(0,"end")
10637  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
10638  if AWGAOffsetvalue < (-2.50-AWGA_Ext_Offset.get()):
10639  AWGAOffsetvalue = -2.50-AWGA_Ext_Offset.get()
10640  AWGAOffsetEntry.delete(0,"end")
10641  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
10642  if AWGAMode.get() == 1: # Source current measure voltage mode
10643  if AWGAOffsetvalue > 200.00:
10644  AWGAOffsetvalue = 200.00
10645  AWGAOffsetEntry.delete(0,"end")
10646  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
10647  if AWGAOffsetvalue < -200.00:
10648  AWGAOffsetvalue = -200.00
10649  AWGAOffsetEntry.delete(0,"end")
10650  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
10651 #
10652 def BAWGAFreq(temp):
10653  global AWGAFreqEntry, AWGAFreqvalue, AWG_2X, LockFreq
10654  global BodeScreenStatus, BodeDisp, AWGRecLength
10655 
10656  try:
10657  AWGAFreqvalue = float(eval(AWGAFreqEntry.get()))
10658  except:
10659  AWGAFreqEntry.delete(0,"end")
10660  AWGAFreqEntry.insert(0, AWGAFreqvalue)
10661  if AWG_2X.get() == 1:
10662  if BodeScreenStatus.get() > 0 and BodeDisp.get() > 0:
10663  if AWGAFreqvalue > 90000: # max freq is 90KHz foe Bode Plots
10664  AWGAFreqvalue = 90000
10665  AWGAFreqEntry.delete(0,"end")
10666  AWGAFreqEntry.insert(0, AWGAFreqvalue)
10667  else:
10668  if AWGAFreqvalue > 50000: # max freq is 50KHz
10669  AWGAFreqvalue = 50000
10670  AWGAFreqEntry.delete(0,"end")
10671  AWGAFreqEntry.insert(0, AWGAFreqvalue)
10672  else:
10673  if AWGAFreqvalue > 25000: # max freq is 25KHz
10674  AWGAFreqvalue = 25000
10675  AWGAFreqEntry.delete(0,"end")
10676  AWGAFreqEntry.insert(0, AWGAFreqvalue)
10677  if AWGAFreqvalue < 4.0:
10678  AWGRecLength = 32768*2
10679  else:
10680  AWGRecLength = 32768
10681  if AWGAFreqvalue < 0: # Set negative frequency entry to 10
10682  AWGAFreqvalue = 10
10683  AWGAFreqEntry.delete(0,"end")
10684  AWGAFreqEntry.insert(0, AWGAFreqvalue)
10685  if LockFreq.get() == 1: # If freq lock flag set change AWGB Freq to same value
10686  AWGBFreqEntry.delete(0,"end")
10687  AWGBFreqEntry.insert(0, AWGAFreqvalue)
10688  #UpdateAWGA()
10689 
10690 def ToggleAWGAPhaseDelay():
10691  global AWGAPhaseDelay, phasealab, awgaph, awgadel
10692 
10693  if AWGAPhaseDelay.get() == 1:
10694  AWGAPhaseDelay.set(0)
10695  awgaph.configure(text="Phase")
10696  phasealab.configure(text="Deg")
10697  elif AWGAPhaseDelay.get() == 0:
10698  AWGAPhaseDelay.set(1)
10699  awgaph.configure(text="Delay")
10700  phasealab.configure(text="mSec")
10701 
10702 def BAWGAPhaseDelay():
10703  global AWGAPhaseDelay, phasealab, awgaph, awgadel
10704 
10705  if AWGAPhaseDelay.get() == 0:
10706  phasealab.configure(text="Deg")
10707  awgaph.configure(text="Phase")
10708  elif AWGAPhaseDelay.get() == 1:
10709  phasealab.configure(text="mSec")
10710  awgaph.configure(text="Delay")
10711 
10712 def BAWGAPhase(temp):
10713  global AWGAPhaseEntry, AWGAPhasevalue
10714 
10715  try:
10716  AWGAPhasevalue = float(eval(AWGAPhaseEntry.get()))
10717  except:
10718  AWGAPhaseEntry.delete(0,"end")
10719  AWGAPhaseEntry.insert(0, AWGAPhasevalue)
10720 
10721  if AWGAPhasevalue > 360: # max phase is 360 degrees
10722  AWGAPhasevalue = 360
10723  AWGAPhaseEntry.delete(0,"end")
10724  AWGAPhaseEntry.insert(0, AWGAPhasevalue)
10725  if AWGAPhasevalue < 0: # min phase is 0 degrees
10726  AWGAPhasevalue = 0
10727  AWGAPhaseEntry.delete(0,"end")
10728  AWGAPhaseEntry.insert(0, AWGAPhasevalue)
10729 
10730 def BAWGADutyCycle(temp):
10731  global AWGADutyCycleEntry, AWGADutyCyclevalue
10732 
10733  try:
10734  AWGADutyCyclevalue = float(eval(AWGADutyCycleEntry.get()))/100
10735  except:
10736  AWGADutyCycleEntry.delete(0,"end")
10737  AWGADutyCycleEntry.insert(0, AWGADutyCyclevalue)
10738 
10739  if AWGADutyCyclevalue > 1: # max duty cycle is 100%
10740  AWGADutyCyclevalue = 1
10741  AWGADutyCycleEntry.delete(0,"end")
10742  AWGADutyCycleEntry.insert(0, AWGADutyCyclevalue*100)
10743  if AWGADutyCyclevalue < 0: # min duty cycle is 0%
10744  AWGADutyCyclevalue = 0
10745  AWGADutyCycleEntry.delete(0,"end")
10746  AWGADutyCycleEntry.insert(0, AWGADutyCyclevalue)
10747  #UpdateAWGA()
10748 
10749 def BAWGAShape():
10750  global AWGAShape, AWGAWave, phasealab, duty1lab
10751 
10752  if AWGAShape.get() == 0:
10753  AWGAWave = 'dc'
10754  duty1lab.config(text="%")
10755  BAWGAPhaseDelay()
10756  if AWGAShape.get() == 1:
10757  AWGAWave = 'sine'
10758  duty1lab.config(text="%")
10759  BAWGAPhaseDelay()
10760  if AWGAShape.get() == 2:
10761  AWGAWave = 'triangle'
10762  duty1lab.config(text="%")
10763  BAWGAPhaseDelay()
10764  if AWGAShape.get() == 3:
10765  AWGAWave = 'sawtooth'
10766  duty1lab.config(text="%")
10767  BAWGAPhaseDelay()
10768  if AWGAShape.get() == 4:
10769  AWGAWave = 'square'
10770  duty1lab.config(text="%")
10771  BAWGAPhaseDelay()
10772  if AWGAShape.get() == 5:
10773  AWGAWave = 'stairstep'
10774  duty1lab.config(text="%")
10775  BAWGAPhaseDelay()
10776  if AWGAShape.get() > 5:
10777  AWGAWave = 'arbitrary'
10778  # UpdateAWGA()
10779 
10780 def AWGAReadFile():
10781  global AWGAwaveform, AWGALength, awgwindow, AWG_2X, AWGA2X, AWGAcsvFile
10782 
10783  # Read values from CVS file
10784  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=awgwindow)
10785  AWGAcsvFile = filename
10786  AWGALoadCSV()
10787 #
10788 def AWGALoadCSV():
10789  global AWGAwaveform, AWGALength, awgwindow, AWG_2X, AWGA2X, AWGAcsvFile, AWGAOffsetvalue
10790 
10791  BAWGAOffset(0)
10792  try:
10793  CSVFile = open(AWGAcsvFile)
10794  # dialect = csv.Sniffer().sniff(CSVFile.read(128))
10795  CSVFile.seek(0)
10796  #csv_f = csv.reader(CSVFile, dialect)
10797  csv_f = csv.reader(CSVFile, csv.excel)
10798  except:
10799  showwarning("WARNING","No such file found or wrong format!", parent=awgwindow)
10800  # print csv_f.dialect
10801  AWGAwaveform = []
10802  ColumnNum = 0
10803  ColumnSel = 0
10804  RowNum = 0
10805  for row in csv_f:
10806  # print 'found row = ', row
10807  if len(row) > 1 and ColumnSel == 0:
10808  RequestColumn = askstring("Which Column?", "File contains 1 to " + str(len(row)) + " columns\n\nEnter column number to import:\n", initialvalue=1, parent=awgwindow)
10809  ColumnNum = int(RequestColumn) - 1
10810  ColumnLen = str(len(row))
10811  ColumnSel = 1
10812  try:
10813  colnum = 0
10814  for col in row:
10815  if colnum == ColumnNum:
10816  AWGAwaveform.append(float(col))
10817  colnum += 1
10818  except:
10819  print( 'skipping non-numeric row', RowNum)
10820  RowNum += 1
10821  AWGAwaveform = numpy.array(AWGAwaveform)
10822  AWGAwaveform = AWGAwaveform + AWGAOffsetvalue # add DC offset from Max entry
10824  CSVFile.close()
10825  UpdateAwgCont()
10826 
10827 # Split 2X sampled AWGAwaveform array into odd and even sample arrays
10828 def SplitAWGAwaveform():
10829  global AWG_2X, AWGA2X, AWGAwaveform
10830  global AWGFiltA, AWGFiltACoef
10831 
10832  # check if AWG digital filter box checked
10833  if AWGFiltA.get() == 1:
10834  BufLen = len(AWGAwaveform)
10835  CoefLen = len(AWGFiltACoef)/2
10836  AWGAwaveform = numpy.pad(AWGAwaveform, (CoefLen,CoefLen), 'wrap')
10837  AWGAwaveform = numpy.convolve(AWGAwaveform, AWGFiltACoef)
10838  AWGAwaveform = numpy.roll(AWGAwaveform, -CoefLen)
10839  AWGAwaveform = AWGAwaveform[CoefLen:BufLen+CoefLen]
10840 
10841  if AWG_2X.get() == 1:
10842  Tempwaveform = []
10843  AWGA2X = []
10844  AWGA2X = AWGAwaveform[1::2] # odd numbered samples
10845  Tempwaveform = AWGAwaveform[::2] # even numbered samples Tempwaveform
10846  AWGAwaveform = Tempwaveform
10847 #
10848 def AWGANumCycles():
10849  global AWGABurstFlag, AWGACycles, AWGABurstDelay
10850 
10851  if AWGABurstFlag.get() == 1:
10852  AWGACyclesString = askstring("AWG A Burst Mode", "Current number of cycles " + str(AWGACycles) + "\n\nNew number of cycles:\n", initialvalue=str(AWGACycles), parent=awgwindow)
10853  if (AWGACyclesString == None): # If Cancel pressed, then None
10854  return
10855  AWGACycles = int(AWGACyclesString)
10856  AWGADelayString = askstring("AWG A Burst Mode", "Current Burst delay " + str(AWGABurstDelay) + "\n\nNew burst delay in mS:\n", initialvalue=str(AWGABurstDelay), parent=awgwindow)
10857  if (AWGADelayString == None): # If Cancel pressed, then None
10858  return
10859  AWGABurstDelay = float(AWGADelayString)
10860  ReMakeAWGwaves()
10861 #
10862 def AWGAReadWAV():
10863  global AWGAwaveform, AWGALength, AWGAShape, awgwindow, AWGBwaveform, AWGBLength, AWGBShape
10864  global AWG_2X, AWGA2X, AWGAwavFile
10865 
10866 # Read values from WAV file
10867  filename = askopenfilename(defaultextension = ".wav", filetypes=[("WAV files", "*.wav")], parent=awgwindow)
10868  AWGAwavFile = filename
10869  AWGALoadWAV()
10870 #
10871 def AWGALoadWAV():
10872  global AWGAwaveform, AWGALength, AWGAShape, awgwindow, AWGBwaveform, AWGBLength, AWGBShape
10873  global AWG_2X, AWGA2X, AWGAwavFile
10874 
10875  try:
10876  spf = wave.open(AWGAwavFile,'r')
10877  except:
10878  showwarning("WARNING","No such file found or wrong format!", parent=awgwindow)
10879  AWGAwaveform = []
10880  AWGBwaveform = []
10881  Length = spf.getnframes()
10882  if Length > 90000:
10883  Length = 90000
10884  # If Stereo put first channel in AWGA and second channel in AWGB
10885  if spf.getnchannels() == 2:
10886  showwarning("Split Stereo","Left to AWGA Right to AWGB", parent=awgwindow)
10887  signal = spf.readframes(Length)
10888  Stereo = numpy.fromstring(signal, 'Int16') # convert strings to Int
10889  n = 0
10890  while n < Length*2:
10891  AWGAwaveform.append((Stereo[n] * 2.5 / 32768) + 2.5)
10892  n = n + 1
10893  AWGBwaveform.append((Stereo[n] * 2.5 / 32768) + 2.5)
10894  n = n + 1
10895  AWGAwaveform = numpy.array(AWGAwaveform)
10896  AWGBwaveform = numpy.array(AWGBwaveform)
10897  AWGBShape.set(AWGAShape.get())
10898  else:
10899  #Extract Raw Audio from Wav File
10900  signal = spf.readframes(Length)
10901  WAVsignal = numpy.fromstring(signal, 'Int16') # convert strings to Int
10902  # offset and scale for 0 5 V range
10903  AWGAwaveform = (WAVsignal * 2.5 / 32768) + 2.5
10904  AWGAwaveform = numpy.array(AWGAwaveform)
10906  spf.close()
10907  UpdateAwgCont()
10908 
10909 def AWGAWriteFile():
10910  global AWGAwaveform, AWGALength, awgwindow
10911 
10912  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=awgwindow)
10913  numpy.savetxt(filename, AWGAwaveform, delimiter=",", fmt='%2.4f')
10914 
10915 def AWGAMakeMath():
10916  global AWGAwaveform, AWGSAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB
10917  global AWGBwaveform, VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGAMathString
10918  global FFTBuffA, FFTBuffB, FFTwindowshape, AWGALength, awgwindow
10919  global DFiltACoef, DFiltBCoef, AWGAShapeLabel, AWGALength
10920  global AWG_2X, AWGA2X
10921 
10922  TempString = AWGAMathString
10923  AWGAShapeLabel.config(text = "Math" ) # change displayed value
10924  AWGAMathString = askstring("AWG A Math Formula", "Current Formula: " + AWGAMathString + "\n\nNew Formula:\n", initialvalue=AWGAMathString, parent=awgwindow)
10925  if (AWGAMathString == None): # If Cancel pressed, then None
10926  AWGAMathString = TempString
10927  return
10928  try:
10929  AWGAwaveform = eval(AWGAMathString)
10930  except:
10931  showwarning("Syntax Error","Syntax Error in entered string!", parent=awgwindow)
10932  AWGAwaveform = numpy.array(AWGAwaveform)
10934  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
10935  UpdateAwgCont()
10936 #
10937 def AWGAConfigMath():
10938  global AWGAwaveform, AWGSAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB
10939  global AWGBwaveform, VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGAMathString
10940  global FFTBuffA, FFTBuffB, FFTwindowshape, AWGALength, awgwindow
10941  global DFiltACoef, DFiltBCoef, AWGAShapeLabel
10942  global AWG_2X, AWGA2X
10943 
10944  AWGAwaveform = eval(AWGAMathString)
10945  AWGAwaveform = numpy.array(AWGAwaveform)
10947  UpdateAwgCont()
10948 #
10949 def AWGAMakeBodeSine():
10950  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
10951  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay, AWGAMode
10952  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, phasealab, AWG_Amp_Mode, AWGRecLength
10953  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10954 
10955  BAWGAAmpl(0)
10956  BAWGAOffset(0)
10957  BAWGAFreq(0)
10958  BAWGAPhase(0)
10959  BAWGADutyCycle(0)
10960  MinFreq = float(AWGSAMPLErate)/float(AWGRecLength)
10961  if AWGAFreqvalue < MinFreq: # if frequency is less than 1 cycle in record length Hz use libsmu sine function
10962  AWGAShape.set(1)
10963  BAWGAShape()
10964  UpdateAwgCont()
10965  return
10966 
10967  if AWGAFreqvalue > 0.0:
10968  if AWG_2X.get() == 1:
10969  AWGAperiodvalue = (BaseSampleRate*2)/AWGAFreqvalue
10970  else:
10971  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
10972  else:
10973  AWGAperiodvalue = 10.0
10974 
10975  if AWGAPhaseDelay.get() == 0:
10976  if AWGAPhasevalue > 0:
10977  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
10978  else:
10979  AWGAdelayvalue = 0.0
10980  elif AWGAPhaseDelay.get() == 1:
10981  AWGAdelayvalue = AWGAPhasevalue * SAMPLErate / 1000
10982  Cycles = int(AWGRecLength/AWGAperiodvalue)
10983  if Cycles < 1:
10984  Cycles = 1
10985  RecLength = int(Cycles * AWGAperiodvalue)
10986  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
10987  RecLength = RecLength + 1
10988  AWGAwaveform = []
10989  AWGAwaveform = numpy.cos(numpy.linspace(0, 2*Cycles*numpy.pi, RecLength))
10990 
10991  if AWG_Amp_Mode.get() == 0:
10992  if AWGAMode.get() == 1: # convert to mA
10993  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2000.0
10994  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2000.0
10995  else:
10996  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2.0
10997  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2.0
10998  else:
10999  if AWGAMode.get() == 1: # convert to mA
11000  amplitude = AWGAAmplvalue/1000.0
11001  offset = AWGAOffsetvalue/1000.0
11002  else:
11003  amplitude = AWGAAmplvalue*AWGA_Ext_Gain.get()
11004  offset = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get()
11005  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
11006  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
11007 #
11009  BAWGAPhaseDelay()
11010  duty1lab.config(text="%")
11011  UpdateAwgCont()
11012 #
11013 def AWGAMakeFMSine():
11014  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
11015  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay, AWGAMode
11016  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, phasealab, AWG_Amp_Mode
11017  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset, AWGRecLength
11018 
11019  BAWGAAmpl(0)
11020  BAWGAOffset(0)
11021  BAWGAFreq(0)
11022 # uses dyty cycle entry for Modulation index and phase entry for Modulation frequency
11023  duty1lab.config(text = "M Index")
11024  phasealab.config(text = "M Freq")
11025 
11026  if AWGAFreqvalue > 0.0:
11027  if AWG_2X.get() == 1:
11028  AWGAperiodvalue = (BaseSampleRate*2)/AWGAFreqvalue
11029  else:
11030  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11031  else:
11032  AWGAperiodvalue = 10.0
11033 
11034  try:
11035  ModFreq = float(eval(AWGAPhaseEntry.get()))
11036  except:
11037  ModFreq = 10
11038  AWGAPhaseEntry.delete(0,"end")
11039  AWGAPhaseEntry.insert(0, ModFreq)
11040 
11041  if ModFreq < 10:
11042  ModFreq = 10
11043  AWGAPhaseEntry.delete(0,"end")
11044  AWGAPhaseEntry.insert(0, ModFreq)
11045 
11046  if AWG_2X.get() == 1:
11047  MODperiodvalue = (BaseSampleRate*2)/ModFreq
11048  else:
11049  MODperiodvalue = BaseSampleRate/ModFreq
11050 
11051  try:
11052  ModIndex = float(eval(AWGADutyCycleEntry.get()))
11053  except:
11054  ModIndex = 1.0
11055  AWGADutyCycleEntry.delete(0,"end")
11056  AWGADutyCycleEntry.insert(0, ModIndex)
11057 
11058  ModCycles = int(AWGRecLength/MODperiodvalue) # find a whole number of cycles
11059  if ModCycles < 1:
11060  ModCycles = 1
11061  RecLength = int(ModCycles * MODperiodvalue)
11062  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11063  RecLength = RecLength + 1
11064  CarCycles = int(RecLength/AWGAperiodvalue) # insure a whole number of carrier cycles in record
11065  AWGAwaveform = []
11066  AWGAwaveform = numpy.sin( (numpy.linspace(0, CarCycles*2*numpy.pi, RecLength)) - ModIndex*numpy.cos(numpy.linspace(0, ModCycles*2*numpy.pi, RecLength)) )
11067  if AWG_Amp_Mode.get() == 0:
11068  if AWGAMode.get() == 1: # convert to mA
11069  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2000.0
11070  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2000.0
11071  else:
11072  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2.0
11073  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2.0
11074  else:
11075  if AWGAMode.get() == 1: # convert to mA
11076  amplitude = AWGAAmplvalue/1000.0
11077  offset = AWGAOffsetvalue/1000.0
11078  else:
11079  amplitude = AWGAAmplvalue*AWGA_Ext_Gain.get()
11080  offset = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get()
11081  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
11082  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
11083 #
11084  SplitAWGAwaveform() # if needed
11085  UpdateAwgCont()
11086 #
11087 def AWGAMakeAMSine():
11088  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
11089  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay, AWGAMode
11090  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, phasealab, AWG_Amp_Mode
11091  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset, AWGRecLength
11092 
11093  BAWGAAmpl(0)
11094  BAWGAOffset(0)
11095  BAWGAFreq(0)
11096 # uses dyty cycle entry for Modulation index and phase entry for Modulation frequency
11097  duty1lab.config(text = "M Index")
11098  phasealab.config(text = "M Freq")
11099 
11100  if AWGAFreqvalue > 0.0:
11101  if AWG_2X.get() == 1:
11102  AWGAperiodvalue = (BaseSampleRate*2)/AWGAFreqvalue
11103  else:
11104  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11105  else:
11106  AWGAperiodvalue = 10.0
11107 
11108  try:
11109  ModFreq = float(eval(AWGAPhaseEntry.get()))
11110  except:
11111  ModFreq = 10
11112  AWGAPhaseEntry.delete(0,"end")
11113  AWGAPhaseEntry.insert(0, ModFreq)
11114 
11115  if ModFreq < 10:
11116  ModFreq = 10
11117  AWGAPhaseEntry.delete(0,"end")
11118  AWGAPhaseEntry.insert(0, ModFreq)
11119 
11120  if AWG_2X.get() == 1:
11121  MODperiodvalue = (BaseSampleRate*2)/ModFreq
11122  else:
11123  MODperiodvalue = BaseSampleRate/ModFreq
11124 
11125  try:
11126  ModIndex = float(eval(AWGADutyCycleEntry.get()))/200.0
11127  except:
11128  ModIndex = 50.0
11129  AWGADutyCycleEntry.delete(0,"end")
11130  AWGADutyCycleEntry.insert(0, ModIndex)
11131 
11132  ModCycles = int(AWGRecLength/MODperiodvalue) # find a whole number of cycles
11133  if ModCycles < 1:
11134  ModCycles = 1
11135  RecLength = int(ModCycles * MODperiodvalue)
11136  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11137  RecLength = RecLength + 1
11138  CarCycles = int(RecLength/AWGAperiodvalue) # insure a whole number of carrier cycles in record
11139  AWGAwaveform = []
11140  AWGAwaveform = numpy.sin(numpy.linspace(0, CarCycles*2*numpy.pi, RecLength)) * (0.5+(ModIndex*(numpy.cos(numpy.linspace(0, ModCycles*2*numpy.pi, RecLength)))))
11141  if AWG_Amp_Mode.get() == 0:
11142  if AWGAMode.get() == 1: # convert to mA
11143  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2000.0
11144  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2000.0
11145  else:
11146  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2.0
11147  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2.0
11148  else:
11149  if AWGAMode.get() == 1: # convert to mA
11150  amplitude = AWGAAmplvalue/1000.0
11151  offset = AWGAOffsetvalue/1000.0
11152  else:
11153  amplitude = AWGAAmplvalue*AWGA_Ext_Gain.get()
11154  offset = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get()
11155  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
11156  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
11157 #
11158  SplitAWGAwaveform() # if needed
11159  UpdateAwgCont()
11160 #
11162  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
11163  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay, AWGAMode
11164  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, phasealab, AWG_Amp_Mode
11165  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset, AWGRecLength
11166 
11167  BAWGAAmpl(0)
11168  BAWGAOffset(0)
11169  BAWGAFreq(0)
11170 #
11171  if AWGAFreqvalue > 0.0:
11172  if AWG_2X.get() == 1:
11173  AWGAperiodvalue = (BaseSampleRate*2)/AWGAFreqvalue
11174  else:
11175  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11176  else:
11177  AWGAperiodvalue = 10.0
11178 
11179  if AWGAPhaseDelay.get() == 0:
11180  if AWGAPhasevalue > 0:
11181  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
11182  else:
11183  AWGAdelayvalue = 0.0
11184  elif AWGAPhaseDelay.get() == 1:
11185  AWGAdelayvalue = AWGAPhasevalue * SAMPLErate / 1000
11186 
11187  Cycles = int(AWGRecLength/AWGAperiodvalue)
11188  if Cycles < 1:
11189  Cycles = 1
11190  RecLength = int(Cycles * AWGAperiodvalue)
11191  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11192  RecLength = RecLength + 1
11193  AWGAwaveform = []
11194  AWGAwaveform = numpy.cos(numpy.linspace(0, 2*Cycles*numpy.pi, RecLength))
11195  AWGAwaveform = numpy.absolute(AWGAwaveform) * -1.0
11196  AWGAwaveform = AWGAwaveform + 0.5
11197  AWGAwaveform = AWGAwaveform * 2.0
11198  if AWG_Amp_Mode.get() == 0:
11199  if AWGAMode.get() == 1: # convert to mA
11200  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2000.0
11201  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2000.0
11202  else:
11203  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2.0
11204  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2.0
11205  else:
11206  if AWGAMode.get() == 1: # convert to mA
11207  amplitude = AWGAAmplvalue/1000.0
11208  offset = AWGAOffsetvalue/1000.0
11209  else:
11210  amplitude = AWGAAmplvalue*AWGA_Ext_Gain.get()
11211  offset = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get()
11212  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
11213  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
11214 #
11216  BAWGAPhaseDelay()
11217  duty1lab.config(text="%")
11218  UpdateAwgCont()
11219 #
11220  SplitAWGAwaveform() # if needed
11221  UpdateAwgCont()
11222 #
11224  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
11225  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay, AWGAMode
11226  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, phasealab, AWG_Amp_Mode
11227  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset, AWGRecLength
11228 
11229  BAWGAAmpl(0)
11230  BAWGAOffset(0)
11231  BAWGAFreq(0)
11232 #
11233  if AWGAFreqvalue > 0.0:
11234  if AWG_2X.get() == 1:
11235  AWGAperiodvalue = (BaseSampleRate*2)/AWGAFreqvalue
11236  else:
11237  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11238  else:
11239  AWGAperiodvalue = 10.0
11240 
11241  if AWGAPhaseDelay.get() == 0:
11242  if AWGAPhasevalue > 0:
11243  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
11244  else:
11245  AWGAdelayvalue = 0.0
11246  elif AWGAPhaseDelay.get() == 1:
11247  AWGAdelayvalue = AWGAPhasevalue * SAMPLErate / 1000
11248 
11249  Cycles = int(AWGRecLength/AWGAperiodvalue)
11250  if Cycles < 1:
11251  Cycles = 1
11252  RecLength = int(Cycles * AWGAperiodvalue)
11253  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11254  RecLength = RecLength + 1
11255  AWGAwaveform = []
11256  AWGAwaveform = numpy.cos(numpy.linspace(0, 2*Cycles*numpy.pi, RecLength))
11257  AWGAwaveform = numpy.minimum(AWGAwaveform, numpy.zeros(RecLength))
11258  AWGAwaveform = AWGAwaveform + 0.5
11259  AWGAwaveform = AWGAwaveform * 2.0
11260  # minimum, maximum
11261  if AWG_Amp_Mode.get() == 0:
11262  if AWGAMode.get() == 1: # convert to mA
11263  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2000.0
11264  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2000.0
11265  else:
11266  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2.0
11267  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2.0
11268  else:
11269  if AWGAMode.get() == 1: # convert to mA
11270  amplitude = AWGAAmplvalue/1000.0
11271  offset = AWGAOffsetvalue/1000.0
11272  else:
11273  amplitude = AWGAAmplvalue*AWGA_Ext_Gain.get()
11274  offset = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get()
11275  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
11276  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
11277 #
11279  BAWGAPhaseDelay()
11280  duty1lab.config(text="%")
11281  UpdateAwgCont()
11282 #
11283  SplitAWGAwaveform() # if needed
11284  UpdateAwgCont()
11285 #
11286 def AWGAMakePWMSine():
11287  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength
11288  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11289  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
11290  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11291 
11292  BAWGAAmpl(0)
11293  BAWGAOffset(0)
11294  BAWGAFreq(0)
11295  BAWGAPhase(0)
11296  BAWGADutyCycle(0)
11297 
11298  if AWGAFreqvalue > 0.0:
11299  if AWG_2X.get() == 1:
11300  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
11301  else:
11302  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11303  else:
11304  AWGAperiodvalue = 0.0
11305  if AWG_Amp_Mode.get() == 1:
11306  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11307  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11308  else:
11309  MaxV = AWGAOffsetvalue
11310  MinV = AWGAAmplvalue
11311 
11312  PulseWidth = int(AWGADutyCyclevalue*100)
11313  PulseSamples = int(AWGAperiodvalue/PulseWidth)
11314  AWGAwaveform = []
11315  for i in range(PulseSamples): #(i = 0; i < cPulse; i++)
11316  v = round(PulseWidth/2*(1+numpy.sin(i*2*numpy.pi/PulseSamples)))
11317  # print(v)
11318  for j in range(PulseWidth): #(j = 0; j < cLength; j++)
11319  if j >= v:
11320  AWGAwaveform.append(MaxV) # j>=v?1:0
11321  else:
11322  AWGAwaveform.append(MinV) # j>=v?1:0
11324  duty1lab.config(text="PWidth")
11325  UpdateAwgCont()
11326 #
11327 def AWGAMakeFourier():
11328  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength
11329  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11330  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
11331  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11332 
11333  BAWGAAmpl(0)
11334  BAWGAOffset(0)
11335  BAWGAFreq(0)
11336  BAWGADutyCycle(0)
11337 
11338  Max_term = int(AWGADutyCyclevalue*100)
11339  if AWG_2X.get() == 1:
11340  TempRate = (BaseSampleRate*2)
11341  else:
11342  TempRate = BaseSampleRate
11343  AWGAwaveform = []
11344  AWGAwaveform = numpy.cos(numpy.linspace(0, 2*numpy.pi, int(TempRate/AWGAFreqvalue))) # the fundamental
11345  k = 3
11346  while k <= Max_term:
11347  # Add odd harmonics up to max_term
11348  Harmonic = (math.sin(k*numpy.pi/2.0)/k)*(numpy.cos(numpy.linspace(0, k*2*numpy.pi, int(TempRate/AWGAFreqvalue))))
11349  AWGAwaveform = AWGAwaveform + Harmonic
11350  k = k + 2 # skip even numbers
11351  if AWG_Amp_Mode.get() == 0:
11352  amplitude = (AWGAOffsetvalue-AWGAAmplvalue)/2.0
11353  offset = (AWGAOffsetvalue+AWGAAmplvalue)/2.0
11354  else:
11355  amplitude = AWGAAmplvalue*AWGA_Ext_Gain.get()
11356  offset = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get()
11357  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
11359  duty1lab.config(text="Harmonics")
11360  BAWGAPhaseDelay()
11361  UpdateAwgCont()
11362 #
11363 def AWGAMakeSinc():
11364  global AWGAwaveform, AWGSampleRate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
11365  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay
11366  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11367  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11368 
11369  BAWGAAmpl(0)
11370  BAWGAOffset(0)
11371  BAWGAFreq(0)
11372  BAWGAPhase(0)
11373  BAWGADutyCycle(0)
11374 
11375  if AWGAFreqvalue > 0.0:
11376  if AWG_2X.get() == 1:
11377  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
11378  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11379  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11380  AWGAperiodvalue = AWGAperiodvalue + 1
11381  else:
11382  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11383  SamplesPermS = int(BaseSampleRate/1000) # 100
11384  else:
11385  AWGAperiodvalue = 0.0
11386  if AWG_Amp_Mode.get() == 1:
11387  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11388  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11389  else:
11390  MaxV = AWGAOffsetvalue
11391  MinV = AWGAAmplvalue
11392 
11393  if AWGAPhaseDelay.get() == 0:
11394  if AWGAPhasevalue > 0:
11395  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
11396  else:
11397  AWGAdelayvalue = 0.0
11398  elif AWGAPhaseDelay.get() == 1:
11399  AWGAdelayvalue = AWGAPhasevalue * SAMPLErate / 1000
11400 
11401  Cycles = int(AWGADutyCyclevalue*100)
11402  NCycles = -1 * Cycles
11403  AWGAwaveform = []
11404  AWGAwaveform = numpy.sinc(numpy.linspace(NCycles, Cycles, int(SAMPLErate/AWGAFreqvalue)))
11405  amplitude = (MaxV-MinV) / 2.0
11406  offset = (MaxV+MinV) / 2.0
11407  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
11408  Cycles = int(37500/AWGAperiodvalue)
11409  if Cycles < 1:
11410  Cycles = 1
11411  if Cycles > 1:
11412  Extend = int((Cycles-1.0)*AWGAperiodvalue/2.0)
11413  AWGAwaveform = numpy.pad(AWGAwaveform, (Extend,Extend), 'wrap')
11414  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
11416  #BAWGAPhaseDelay()
11417  duty1lab.config(text="Cycles")
11418  BAWGAPhaseDelay()
11419  UpdateAwgCont()
11420 #
11421 def AWGAMakeSSQ():
11422  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, phasealab, duty1lab
11423  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11424  global AWGABurstFlag, AWGACycles, AWGABurstDelay
11425  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
11426  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11427 
11428  BAWGAAmpl(0)
11429  BAWGAOffset(0)
11430  BAWGAFreq(0)
11431  BAWGAPhase(0)
11432  BAWGADutyCycle(0)
11433 
11434  if AWGAFreqvalue > 0.0:
11435  if AWG_2X.get() == 1:
11436  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
11437  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11438  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11439  AWGAperiodvalue = AWGAperiodvalue + 1
11440  else:
11441  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11442  SamplesPermS = int(BaseSampleRate/1000) # 100
11443  else:
11444  AWGAperiodvalue = 0.0
11445  if AWG_Amp_Mode.get() == 1:
11446  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11447  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11448  else:
11449  MaxV = AWGAOffsetvalue
11450  MinV = AWGAAmplvalue
11451  AWGAwaveform = []
11452  SlopeValue = int(AWGAPhasevalue*SamplesPermS)
11453  if SlopeValue <= 0:
11454  SlopeValue = 1
11455  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue)
11456  if PulseWidth <=0:
11457  PulseWidth = 1
11458  Remainder = int((AWGAperiodvalue - PulseWidth - SlopeValue)/2)
11459  if Remainder <= 0:
11460  Remainder = 1
11461  PulseWidth = PulseWidth - SlopeValue
11462  if PulseWidth <=0:
11463  PulseWidth = 1
11464  StepAmp = (MaxV - MinV)/2
11465  StepOff = (MaxV + MinV)/2
11466  AWGAwaveform = StepAmp * (numpy.cos(numpy.linspace(0, 2*numpy.pi, SlopeValue*2))) + StepOff
11467  MidArray = numpy.ones(PulseWidth) * MinV
11468  AWGAwaveform = numpy.insert(AWGAwaveform, SlopeValue, MidArray)
11469  AWGAwaveform = numpy.pad(AWGAwaveform, (Remainder, Remainder), 'edge')
11470  if AWGABurstFlag.get() == 1:
11471  TempOneCycle = AWGAwaveform
11472  for i in range(AWGACycles-1):
11473  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
11474  TempDelay = int(AWGABurstDelay*SamplesPermS/2) # convert mS to samples
11475  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, TempDelay), 'edge')
11477  duty1lab.config(text="%")
11478  phasealab.config(text = "Rise Time")
11479  UpdateAwgCont()
11480 #
11481 def AWGAMakeTrapazoid():
11482  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, phasealab, duty1lab
11483  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11484  global AWGABurstFlag, AWGACycles, AWGABurstDelay
11485  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
11486  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11487 
11488  BAWGAAmpl(0)
11489  BAWGAOffset(0)
11490  BAWGAFreq(0)
11491  BAWGAPhase(0)
11492  BAWGADutyCycle(0)
11493 
11494  if AWGAFreqvalue > 0.0:
11495  if AWG_2X.get() == 1:
11496  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
11497  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11498  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11499  AWGAperiodvalue = AWGAperiodvalue + 1
11500  else:
11501  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11502  SamplesPermS = int(BaseSampleRate/1000) # 100
11503  else:
11504  AWGAperiodvalue = 0.0
11505  if AWG_Amp_Mode.get() == 1:
11506  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11507  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11508  else:
11509  MaxV = AWGAOffsetvalue
11510  MinV = AWGAAmplvalue
11511  AWGAwaveform = []
11512  SlopeValue = int(AWGAPhasevalue*SamplesPermS) # convert mS to samples
11513  if SlopeValue <= 0:
11514  SlopeValue = 1
11515  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue)
11516  if PulseWidth <=0:
11517  PulseWidth = 1
11518  Remainder = int(AWGAperiodvalue - PulseWidth) - SlopeValue
11519  if Remainder <= 0:
11520  Remainder = 1
11521  PulseWidth = PulseWidth - SlopeValue
11522  if PulseWidth <=0:
11523  PulseWidth = 1
11524  StepValue = (MaxV - MinV) / SlopeValue
11525  SampleValue = MinV
11526  for i in range(SlopeValue):
11527  AWGAwaveform.append(SampleValue)
11528  SampleValue = SampleValue + StepValue
11529  for i in range(PulseWidth):
11530  AWGAwaveform.append(MaxV)
11531  for i in range(SlopeValue):
11532  AWGAwaveform.append(SampleValue)
11533  SampleValue = SampleValue - StepValue
11534  for i in range(Remainder):
11535  AWGAwaveform.append(MinV)
11536  if AWGABurstFlag.get() == 1:
11537  TempOneCycle = AWGAwaveform
11538  for i in range(AWGACycles-1):
11539  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
11540  TempDelay = int(AWGABurstDelay*SamplesPermS/2) # convert mS to samples
11541  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, TempDelay), 'edge')
11543  duty1lab.config(text="%")
11544  phasealab.config(text = "Rise Time")
11545  UpdateAwgCont()
11546 #
11547 def AWGAMakePulse():
11548  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, phasealab, duty1lab
11549  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11550  global AWGABurstFlag, AWGACycles, AWGABurstDelay
11551  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
11552  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11553 
11554  BAWGAAmpl(0)
11555  BAWGAOffset(0)
11556  BAWGAFreq(0)
11557  BAWGAPhase(0)
11558 
11559  try:
11560  AWGADutyCyclevalue = float(eval(AWGADutyCycleEntry.get()))
11561  except:
11562  AWGADutyCycleEntry.delete(0,"end")
11563  AWGADutyCycleEntry.insert(0, AWGADutyCyclevalue)
11564 
11565  if AWGAFreqvalue > 0.0:
11566  if AWG_2X.get() == 1:
11567  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
11568  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11569  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11570  AWGAperiodvalue = AWGAperiodvalue + 1
11571  else:
11572  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11573  SamplesPermS = int(BaseSampleRate/1000) # 100
11574  else:
11575  AWGAperiodvalue = 0.0
11576  if AWG_Amp_Mode.get() == 1:
11577  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11578  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11579  else:
11580  MaxV = AWGAOffsetvalue
11581  MinV = AWGAAmplvalue
11582  AWGAwaveform = []
11583  SlopeValue = int(AWGAPhasevalue*SamplesPermS) # convert mS to samples
11584  if SlopeValue <= 0:
11585  SlopeValue = 1
11586  PulseWidth = int(AWGADutyCyclevalue*SamplesPermS) # convert mS to samples
11587  if PulseWidth <=0:
11588  PulseWidth = 1
11589  Remainder = int(AWGAperiodvalue - PulseWidth) - SlopeValue
11590  if Remainder <= 0:
11591  Remainder = 1
11592  PulseWidth = PulseWidth - SlopeValue
11593  if PulseWidth <=0:
11594  PulseWidth = 1
11595  StepValue = (MaxV - MinV) / SlopeValue
11596  SampleValue = MinV
11597  for i in range(SlopeValue):
11598  AWGAwaveform.append(SampleValue)
11599  SampleValue = SampleValue + StepValue
11600  for i in range(PulseWidth):
11601  AWGAwaveform.append(MaxV)
11602  for i in range(SlopeValue):
11603  AWGAwaveform.append(SampleValue)
11604  SampleValue = SampleValue - StepValue
11605  for i in range(Remainder):
11606  AWGAwaveform.append(MinV)
11607  if AWGABurstFlag.get() == 1:
11608  TempOneCycle = AWGAwaveform
11609  for i in range(AWGACycles-1):
11610  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
11611  TempDelay = int(AWGABurstDelay*SamplesPermS/2) # convert mS to samples
11612  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, TempDelay), 'edge')
11614  duty1lab.config(text="Width mS")
11615  phasealab.config(text = "Rise Time")
11616  UpdateAwgCont()
11617 #
11618 def AWGAMakeRamp():
11619  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, phasealab, duty1lab
11620  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11621  global AWGABurstFlag, AWGACycles, AWGABurstDelay
11622  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
11623  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11624 
11625  BAWGAAmpl(0)
11626  BAWGAOffset(0)
11627  BAWGAFreq(0)
11628  BAWGAPhase(0)
11629  BAWGADutyCycle(0)
11630 
11631  if AWGAFreqvalue > 0.0:
11632  if AWG_2X.get() == 1:
11633  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
11634  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11635  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11636  AWGAperiodvalue = AWGAperiodvalue + 1
11637  else:
11638  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11639  SamplesPermS = int(BaseSampleRate/1000) # 100
11640  else:
11641  AWGAperiodvalue = 0.0
11642  if AWG_Amp_Mode.get() == 1:
11643  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11644  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11645  else:
11646  MaxV = AWGAOffsetvalue
11647  MinV = AWGAAmplvalue
11648  AWGAwaveform = []
11649  SlopeValue = int(AWGAPhasevalue*SamplesPermS) # convert mS to samples
11650  if SlopeValue <= 0:
11651  SlopeValue = 1
11652  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue)
11653  if PulseWidth <=0:
11654  PulseWidth = 1
11655  Remainder = int(AWGAperiodvalue - PulseWidth)
11656  if Remainder <= 0:
11657  Remainder = 1
11658  PulseWidth = PulseWidth - SlopeValue
11659  if PulseWidth <=0:
11660  PulseWidth = 1
11661  StepValue = (MaxV - MinV) / SlopeValue
11662  SampleValue = MinV
11663  for i in range(SlopeValue):
11664  AWGAwaveform.append(SampleValue)
11665  SampleValue = SampleValue + StepValue
11666  for i in range(PulseWidth):
11667  AWGAwaveform.append(MaxV)
11668  for i in range(Remainder):
11669  AWGAwaveform.append(MinV)
11670  if AWGABurstFlag.get() == 1:
11671  TempOneCycle = AWGAwaveform
11672  for i in range(AWGACycles-1):
11673  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
11674  TempDelay = int(AWGABurstDelay*SamplesPermS/2) # convert mS to samples
11675  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, TempDelay), 'edge')
11677  duty1lab.config(text="%")
11678  phasealab.config(text = "Slope Time")
11679  UpdateAwgCont()
11680 #
11681 def AWGAMakeUpDownRamp():
11682  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, duty1lab
11683  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11684  global AWGABurstFlag, AWGACycles, AWGABurstDelay
11685  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
11686  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11687 
11688  BAWGAAmpl(0)
11689  BAWGAOffset(0)
11690  BAWGAFreq(0)
11691  BAWGAPhase(0)
11692  BAWGADutyCycle(0)
11693 
11694  if AWGAFreqvalue > 0.0:
11695  if AWG_2X.get() == 1:
11696  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
11697  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11698  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11699  AWGAperiodvalue = AWGAperiodvalue + 1
11700  else:
11701  AWGAperiodvalue = AWGSAMPLErate/AWGAFreqvalue
11702  SamplesPermS = int(BaseSampleRate/1000) # 100
11703  else:
11704  AWGAperiodvalue = 0.0
11705  if AWG_Amp_Mode.get() == 1:
11706  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11707  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11708  else:
11709  MaxV = AWGAOffsetvalue
11710  MinV = AWGAAmplvalue
11711  #
11712  if AWGAPhaseDelay.get() == 0:
11713  if AWGAPhasevalue > 0:
11714  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
11715  else:
11716  AWGAdelayvalue = 0.0
11717  elif AWGAPhaseDelay.get() == 1:
11718  AWGAdelayvalue = AWGAPhasevalue * SAMPLErate / 1000
11719  #
11720  AWGAwaveform = []
11721  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue)
11722  if PulseWidth <=0:
11723  PulseWidth = 1
11724  Remainder = int(AWGAperiodvalue - PulseWidth)
11725  if Remainder <= 0:
11726  Remainder = 1
11727  UpStepValue = (MaxV - MinV) / PulseWidth
11728  DownStepValue = (MaxV - MinV) / Remainder
11729  SampleValue = MinV
11730  for i in range(PulseWidth):
11731  AWGAwaveform.append(SampleValue)
11732  SampleValue = SampleValue + UpStepValue
11733  for i in range(Remainder):
11734  AWGAwaveform.append(SampleValue)
11735  SampleValue = SampleValue - DownStepValue
11736  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
11737  if AWGABurstFlag.get() == 1:
11738  TempOneCycle = AWGAwaveform
11739  for i in range(AWGACycles-1):
11740  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
11741  TempDelay = int(AWGABurstDelay*SamplesPermS) # convert mS to samples
11742  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, 0), 'edge')
11744  BAWGAPhaseDelay()
11745  duty1lab.config(text = "Symmetry")
11746  BAWGAPhaseDelay()
11747  UpdateAwgCont()
11748 #
11749 def AWGAMakeImpulse():
11750  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11751  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue
11752  global AWGABurstFlag, AWGACycles, AWGABurstDelay
11753  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
11754  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11755 
11756  BAWGAAmpl(0)
11757  BAWGAOffset(0)
11758  BAWGAFreq(0)
11759  BAWGAPhase(0)
11760  BAWGADutyCycle(0)
11761 
11762  if AWGAFreqvalue > 0.0:
11763  if AWG_2X.get() == 1:
11764  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
11765  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11766  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11767  AWGAperiodvalue = AWGAperiodvalue + 1
11768  else:
11769  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11770  SamplesPermS = int(BaseSampleRate/1000) # 100
11771  else:
11772  AWGAperiodvalue = 0.0
11773  if AWG_Amp_Mode.get() == 1:
11774  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11775  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11776  else:
11777  MaxV = AWGAOffsetvalue
11778  MinV = AWGAAmplvalue
11779  AWGAwaveform = []
11780  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue / 2.0)
11781  if AWGAPhaseDelay.get() == 0:
11782  DelayValue = int(AWGAperiodvalue*(AWGAPhasevalue/360))
11783  elif AWGAPhaseDelay.get() == 1:
11784  DelayValue = int(AWGAPhasevalue*SamplesPermS)
11785  for i in range(DelayValue-PulseWidth):
11786  AWGAwaveform.append((MinV+MaxV)/2.0)
11787  for i in range(PulseWidth):
11788  AWGAwaveform.append(MaxV)
11789  for i in range(PulseWidth):
11790  AWGAwaveform.append(MinV)
11791  DelayValue = int(AWGAperiodvalue-DelayValue)
11792  for i in range(DelayValue-PulseWidth):
11793  AWGAwaveform.append((MinV+MaxV)/2.0)
11794  if AWGABurstFlag.get() == 1:
11795  TempOneCycle = AWGAwaveform
11796  for i in range(AWGACycles-1):
11797  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
11798  TempDelay = int(AWGABurstDelay*SamplesPermS) # convert mS to samples
11799  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, 0), 'edge')
11801  duty1lab.config(text = "Duty Cycle")
11802  BAWGAPhaseDelay()
11803  UpdateAwgCont()
11804 
11805 def AWGAMakeUUNoise():
11806  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGAFreqvalue
11807  global AWGALength, AWGAperiodvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11808  global AWGABurstFlag, AWGACycles, AWGABurstDelay
11809  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
11810  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11811 
11812  BAWGAAmpl(0)
11813  BAWGAOffset(0)
11814  BAWGAFreq(0)
11815 
11816  if AWGAFreqvalue > 0.0:
11817  if AWG_2X.get() == 1:
11818  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
11819  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11820  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11821  AWGAperiodvalue = AWGAperiodvalue + 1
11822  else:
11823  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11824  SamplesPermS = int(BaseSampleRate/1000) # 100
11825  else:
11826  AWGAperiodvalue = 0.0
11827  if AWG_Amp_Mode.get() == 1:
11828  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11829  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11830  else:
11831  if AWGAAmplvalue > AWGAOffsetvalue:
11832  MinV = AWGAOffsetvalue
11833  MaxV = AWGAAmplvalue
11834  else:
11835  MaxV = AWGAOffsetvalue
11836  MinV = AWGAAmplvalue
11837  AWGAwaveform = []
11838  AWGAwaveform = numpy.random.uniform(MinV, MaxV, int(AWGAperiodvalue))
11839  Mid = (MaxV+MinV)/2.0
11840  if AWGABurstFlag.get() == 1:
11841  TempOneCycle = AWGAwaveform
11842  for i in range(AWGACycles-1):
11843  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
11844  TempDelay = int(AWGABurstDelay*SamplesPermS) # convert mS to samples
11845  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, 0), 'constant', constant_values=(Mid))
11847  BAWGAPhaseDelay()
11848  UpdateAwgCont()
11849 
11850 def AWGAMakeUGNoise():
11851  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGAFreqvalue
11852  global AWGALength, AWGAperiodvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11853  global AWGABurstFlag, AWGACycles, AWGABurstDelay
11854  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
11855  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11856 
11857  BAWGAAmpl(0)
11858  BAWGAOffset(0)
11859  BAWGAFreq(0)
11860 
11861  if AWGAFreqvalue > 0.0:
11862  if AWG_2X.get() == 1:
11863  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
11864  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11865  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11866  AWGAperiodvalue = AWGAperiodvalue + 1
11867  else:
11868  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11869  SamplesPermS = int(BaseSampleRate/1000) # 100
11870  else:
11871  AWGAperiodvalue = 0.0
11872  if AWG_Amp_Mode.get() == 1:
11873  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11874  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11875  else:
11876  if AWGAAmplvalue > AWGAOffsetvalue:
11877  MinV = AWGAOffsetvalue
11878  MaxV = AWGAAmplvalue
11879  else:
11880  MaxV = AWGAOffsetvalue
11881  MinV = AWGAAmplvalue
11882  AWGAwaveform = []
11883  AWGAwaveform = numpy.random.normal((MinV+MaxV)/2, (MaxV-MinV)/3, int(AWGAperiodvalue))
11884  Mid = (MaxV+MinV)/2.0
11885  if AWGABurstFlag.get() == 1:
11886  TempOneCycle = AWGAwaveform
11887  for i in range(AWGACycles-1):
11888  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
11889  TempDelay = int(AWGABurstDelay*SamplesPermS) # convert mS to samples
11890  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, 0), 'constant', constant_values=(Mid))
11892  BAWGAPhaseDelay()
11893  UpdateAwgCont()
11894 
11895 def BAWGAModeLabel():
11896  global AWGAMode, AWGAIOMode, AWGAModeLabel, DevID, session, devx, DevOne, CHA, HWRevOne
11897  global EnableScopeOnly, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11898 
11899  if AWGAMode.get() == 0: # Source Voltage measure current mode
11900  label_txt = "SVMI"
11901  elif AWGAMode.get() == 1: # Source current measure voltage mode
11902  label_txt = "SIMV"
11903  elif AWGAMode.get() == 2: # High impedance mode
11904  label_txt = "Hi-Z"
11905  if AWGAIOMode.get() > 0: # Split Input / Output mode
11906  if HWRevOne == "D":
11907  if AWGAMode.get() == 0:
11908  AWGAMode.set(1)
11909  CHA.set_mode('i') # channel must be in source current mode for rev D boards
11910  label_txt = "SIMV"
11911  label_txt = label_txt + " Split I/O"
11912  if EnableScopeOnly == 0:
11913  label_txt = label_txt + " Mode"
11914  AWGAModeLabel.config(text = label_txt ) # change displayed value
11915  ReMakeAWGwaves()
11916  #UpdateAwgCont()
11917 
11918 def UpdateAWGA():
11919  global AWGAAmplvalue, AWGAOffsetvalue, EnableScopeOnly
11920  global AWGAFreqvalue, AWGAPhasevalue, AWGAPhaseDelay
11921  global AWGADutyCyclevalue, FSweepMode, AWGARepeatFlag, AWGSync
11922  global AWGAWave, AWGAMode, AWGATerm, AWGAwaveform, AWGAIOMode
11923  global CHA, CHB, AWGSAMPLErate, DevID, devx, HWRevOne, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11924  global amp1lab, off1lab, AWGA2X, AWGA2X, AWGBWave, AWGBRepeatFlag
11925  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11926 
11927  BAWGAAmpl(0)
11928  BAWGAOffset(0)
11929  BAWGAFreq(0)
11930  BAWGAPhase(0)
11931  BAWGADutyCycle(0)
11932  BAWGAShape()
11933 
11934  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode, 1 = Amp/Offset
11935  amp1lab.config(text = "Min Ch A" ) # change displayed value
11936  off1lab.config(text = "Max Ch A" ) # change displayed value
11937  else:
11938  amp1lab.config(text = "Amp Ch A" )
11939  off1lab.config(text = "Off Ch A" )
11940 
11941  if AWGAFreqvalue > 0.0:
11942  AWGAperiodvalue = AWGSAMPLErate/AWGAFreqvalue
11943  else:
11944  AWGAperiodvalue = 0.0
11945 
11946  if AWGAPhaseDelay.get() == 0:
11947  if AWGAWave == 'square':
11948  AWGAPhasevalue = AWGAPhasevalue + 270.0
11949  if AWGAPhasevalue > 359:
11950  AWGAPhasevalue = AWGAPhasevalue - 360
11951  if AWGAPhasevalue > 0:
11952  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
11953  else:
11954  AWGAdelayvalue = 0.0
11955  elif AWGAPhaseDelay.get() == 1:
11956  AWGAdelayvalue = AWGAPhasevalue * 100
11957 
11958  if AWGATerm.get() == 0: # Open termination
11959  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
11960  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
11961  elif AWGATerm.get() == 1: # 50 Ohm termination to GND
11962  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
11963  devx.ctrl_transfer( 0x40, 0x50, 33, 0, 0, 0, 100) # set GND switch to closed
11964  elif AWGATerm.get() == 2: # 50 Ohm termination to +2.5 Volts
11965  devx.ctrl_transfer( 0x40, 0x50, 32, 0, 0, 0, 100) # set 2.5 V switch to closed
11966  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
11967 
11968  if AWGAWave == 'dc':
11969  if AWG_2X.get() == 2:
11970  AWGAWave == 'arbitrary'
11971  CHA.arbitrary(AWGB2X, AWGBRepeatFlag.get())
11972  else:
11973  if AWGAMode.get() == 0: # Source Voltage measure current mode
11974  if AWGAIOMode.get() == 0:
11975  CHA.mode = Mode.SVMI # Put CHA in SVMI mode
11976  else:
11977  CHA.mode = Mode.SVMI_SPLIT # Put CHA in SVMI split mode
11978  CHA.constant(AWGAOffsetvalue)
11979  #
11980  if AWGAMode.get() == 1: # Source current measure voltage mode
11981  if AWGAIOMode.get() == 0:
11982  CHA.mode = Mode.SIMV # Put CHA in SIMV mode
11983  else:
11984  CHA.mode = Mode.SIMV_SPLIT # Put CHA in SIMV split mode
11985  CHA.constant(AWGAOffsetvalue/1000)
11986  #
11987  if AWGAMode.get() == 2: # High impedance mode
11988  if AWGAIOMode.get() == 0:
11989  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
11990  else:
11991  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
11992  #
11993  if AWGAIOMode.get() > 0: # Split Input / Output mode
11994  if HWRevOne == "D":
11995  AWGAMode.set(1)
11996  CHA.mode = Mode.SIMV_SPLIT # channel must be in source current mode
11997 #
11998  else:
11999  if AWGAMode.get() == 0: # Source Voltage measure current mode
12000  if AWGAIOMode.get() == 0:
12001  CHA.mode = Mode.SVMI # Put CHA in SVMI mode
12002  else:
12003  CHA.mode = Mode.SVMI_SPLIT # Put CHA in SVMI split mode
12004  if AWGAMode.get() == 1: # Source current measure voltage mode
12005  if AWGAIOMode.get() == 0:
12006  CHA.mode = Mode.SIMV # Put CHA in SIMV mode
12007  else:
12008  CHA.mode = Mode.SIMV_SPLIT # Put CHA in SIMV split mode
12009  AWGAOffsetvalue = AWGAOffsetvalue/1000
12010  AWGAAmplvalue = AWGAAmplvalue/1000
12011  if AWGAMode.get() == 2: # High impedance mode
12012  if AWGAIOMode.get() == 0:
12013  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
12014  else:
12015  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
12016  else:
12017  if AWG_Amp_Mode.get() == 1:
12018  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
12019  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
12020  else:
12021  MaxV = AWGAOffsetvalue
12022  MinV = AWGAAmplvalue
12023  try:
12024  if AWGAWave == 'sine':
12025  CHA.sine(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue)
12026  elif AWGAWave == 'triangle':
12027  CHA.triangle(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue)
12028  elif AWGAWave == 'sawtooth':
12029  CHA.sawtooth(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue)
12030  elif AWGAWave == 'square':
12031  CHA.square(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue, AWGADutyCyclevalue)
12032  elif AWGAWave == 'stairstep':
12033  CHA.stairstep(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue)
12034  elif AWGAWave == 'arbitrary':
12035  if EnableScopeOnly == 0:
12036  AddAWGANoise()
12037  if AWGSync.get() == 0:
12038  AWGARepeatFlag.set(1)
12039  if AWG_2X.get() == 2:
12040  AWGAWave == 'arbitrary'
12041  CHA.arbitrary(AWGB2X, AWGBRepeatFlag.get())
12042  else:
12043  CHA.arbitrary(AWGAwaveform, AWGARepeatFlag.get()) # set repeat flag
12044  except:
12045  donothing()
12046  if AWGAIOMode.get() > 0: # Split Input / Output mode
12047  if HWRevOne == "D":
12048  AWGAMode.set(1)
12049  CHA.mode = Mode.SIMV_SPLIT # channel must be in source current mode
12050 #
12051 def AddAWGANoise():
12052  global AWG_2X, AWGB2X, AWGAwaveform
12053  global AWGANoiseEntry, AWGAsbnoise, AWGANoisevalue
12054 
12055  if AWGAsbnoise.get() == "None":
12056  return
12057  else:
12058  try:
12059  AWGANoisevalue = float(eval(AWGANoiseEntry.get()))
12060  except:
12061  AWGANoiseEntry.delete(0,"end")
12062  AWGANoiseEntry.insert(0, AWGANoisevalue)
12063  if AWGANoisevalue == 0.0:
12064  return
12065  AWGANoiseform = []
12066  if AWGAsbnoise.get() == "Gaussian":
12067  AWGANoiseform = numpy.random.normal(0.0, abs((AWGANoisevalue)/3), len(AWGAwaveform))
12068  else:
12069  AWGANoiseform = numpy.random.uniform((-AWGANoisevalue)/2, (AWGANoisevalue)/2, len(AWGAwaveform))
12070  AWGAwaveform = AWGAwaveform + AWGANoiseform
12071  if AWG_2X.get() == 2:
12072  if AWGAsbnoise.get() == "Gaussian":
12073  AWGANoiseform = numpy.random.normal(0.0, abs((AWGANoisevalue)/3), len(AWGB2X))
12074  else:
12075  AWGANoiseform = numpy.random.uniform((-AWGANoisevalue)/2, (AWGANoisevalue)/2, len(AWGB2X))
12076  AWGB2X = AWGB2X + AWGANoiseform
12077 
12078 def SetBCompA():
12079  global AWGAAmplEntry, AWGBAmplEntry, AWGAOffsetEntry, AWGBOffsetEntry, AWGAFreqEntry, AWGBFreqEntry
12080  global AWGAPhaseEntry, AWGBPhaseEntry, AWGADutyCycleEntry, AWGBDutyCycleEntry, AWGAShape, AWGBShape
12081  global BisCompA, AWGAWave
12082 
12083  # if BisCompA.get() == 1:
12084  # sawp Min and Max values
12085  if AWGAWave == 'dc':
12086  AWGBAmplvalue = float(eval(AWGAAmplEntry.get()))
12087  AWGBOffsetvalue = 2.5 - (float(eval(AWGAOffsetEntry.get()))-2.5)
12088  AWGBAmplEntry.delete(0,"end")
12089  AWGBAmplEntry.insert(0, AWGBAmplvalue)
12090  AWGBOffsetEntry.delete(0,"end")
12091  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
12092  else:
12093  AWGBAmplvalue = float(eval(AWGAAmplEntry.get()))
12094  AWGBOffsetvalue = float(eval(AWGAOffsetEntry.get()))
12095  AWGBAmplEntry.delete(0,"end")
12096  AWGBAmplEntry.insert(0, AWGBOffsetvalue)
12097  AWGBOffsetEntry.delete(0,"end")
12098  AWGBOffsetEntry.insert(0, AWGBAmplvalue)
12099  # copy everything else
12100  AWGBFreqvalue = float(eval(AWGAFreqEntry.get()))
12101  AWGBFreqEntry.delete(0,"end")
12102  AWGBFreqEntry.insert(0, AWGBFreqvalue)
12103  AWGBPhasevalue = float(eval(AWGAPhaseEntry.get()))
12104  AWGBPhaseEntry.delete(0,"end")
12105  AWGBPhaseEntry.insert(0, AWGBPhasevalue)
12106  AWGBDutyCyclevalue = float(eval(AWGADutyCycleEntry.get()))
12107  AWGBDutyCycleEntry.delete(0,"end")
12108  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue)
12109  AWGBShape.set(AWGAShape.get())
12110  #
12111 # ReMakeAWGwaves()
12112 # UpdateAwgCont()
12113 #
12114 # AWG B functions
12115 def AWGBNumCycles():
12116  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
12117 
12118  if AWGBBurstFlag.get() == 1:
12119  AWGBCyclesString = askstring("AWG B Burst Mode", "Current number of cycles " + str(AWGBCycles) + "\n\nNew number of cycles:\n", initialvalue=str(AWGBCycles), parent=awgwindow)
12120  if (AWGBCyclesString == None): # If Cancel pressed, then None
12121  return
12122  AWGBCycles = int(AWGBCyclesString)
12123  AWGBDelayString = askstring("AWG B Burst Mode", "Current Burst delay " + str(AWGBBurstDelay) + "\n\nNew burst delay in mS:\n", initialvalue=str(AWGBBurstDelay), parent=awgwindow)
12124  if (AWGBDelayString == None): # If Cancel pressed, then None
12125  return
12126  AWGBBurstDelay = float(AWGBDelayString)
12127  ReMakeAWGwaves()
12128 #
12129 def BAWGBAmpl(temp):
12130  global AWGBAmplEntry, AWGBAmplvalue, AWGBMode, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12131  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12132 
12133  try:
12134  AWGBAmplvalue = float(eval(AWGBAmplEntry.get()))
12135  except:
12136  AWGBAmplEntry.delete(0,"end")
12137  AWGBAmplEntry.insert(0, AWGBAmplvalue)
12138  #
12139  if AWGBMode.get() == 0: # Source Voltage measure current mode
12140  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max
12141  if AWGBAmplvalue > 5.00:
12142  AWGBAmplvalue = 5.00
12143  AWGBAmplEntry.delete(0,"end")
12144  AWGBAmplEntry.insert(0, AWGBAmplvalue)
12145  if AWGBAmplvalue < 0.00:
12146  AWGBAmplvalue = 0.00
12147  AWGBAmplEntry.delete(0,"end")
12148  AWGBAmplEntry.insert(0, AWGBAmplvalue)
12149  elif AWG_Amp_Mode.get() == 1: # 1 = Amp/Offset
12150  if AWGBAmplvalue > (2.5 / AWGB_Ext_Gain.get()):
12151  AWGBAmplvalue = 2.5 / AWGB_Ext_Gain.get()
12152  AWGBAmplEntry.delete(0,"end")
12153  AWGBAmplEntry.insert(0, AWGBAmplvalue)
12154  if AWGBAmplvalue < (-2.50 / AWGB_Ext_Gain.get()):
12155  AWGBAmplvalue = -2.50 / AWGB_Ext_Gain.get()
12156  AWGBAmplEntry.delete(0,"end")
12157  AWGBAmplEntry.insert(0, AWGBAmplvalue)
12158  elif AWGBMode.get() == 1: # Source current measure voltage mode
12159  if AWGBAmplvalue > 200.00:
12160  AWGBAmplvalue = 200.00
12161  AWGBAmplEntry.delete(0,"end")
12162  AWGBAmplEntry.insert(0, AWGBAmplvalue)
12163  if AWGBAmplvalue < -200.00:
12164  AWGBAmplvalue = -200.00
12165  AWGBAmplEntry.delete(0,"end")
12166  AWGBAmplEntry.insert(0, AWGBAmplvalue)
12167 #
12168 def BAWGBOffset(temp):
12169  global AWGBOffsetEntry, AWGBOffsetvalue, AWGBMode, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12170  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12171 
12172  try:
12173  AWGBOffsetvalue = float(eval(AWGBOffsetEntry.get()))
12174  except:
12175  AWGBOffsetEntry.delete(0,"end")
12176  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
12177  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode
12178  if AWGBMode.get() == 0: # Source Voltage measure current mode
12179  if AWGBOffsetvalue > 5.00:
12180  AWGBOffsetvalue = 5.00
12181  AWGBOffsetEntry.delete(0,"end")
12182  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
12183  if AWGBOffsetvalue < 0.00:
12184  AWGBOffsetvalue = 0.00
12185  AWGBOffsetEntry.delete(0,"end")
12186  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
12187  elif AWG_Amp_Mode.get() == 1: # 1 = Amp/Offset
12188  if AWGBOffsetvalue > (2.50-AWGB_Ext_Offset.get()):
12189  AWGBOffsetvalue = 2.50-AWGB_Ext_Offset.get()
12190  AWGBOffsetEntry.delete(0,"end")
12191  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
12192  if AWGBOffsetvalue < (-2.50-AWGB_Ext_Offset.get()):
12193  AWGBOffsetvalue = -2.50-AWGB_Ext_Offset.get()
12194  AWGBOffsetEntry.delete(0,"end")
12195  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
12196  if AWGBMode.get() == 1: # Source current measure voltage mode
12197  if AWGBOffsetvalue > 200.00:
12198  AWGBOffsetvalue = 200.00
12199  AWGBOffsetEntry.delete(0,"end")
12200  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
12201  if AWGBOffsetvalue < -200.00:
12202  AWGBOffsetvalue = -200.00
12203  AWGBOffsetEntry.delete(0,"end")
12204  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
12205 #
12206 def BAWGBFreq(temp):
12207  global AWGBFreqEntry, AWGBFreqvalue, AWG_2X
12208  global BodeScreenStatus, BodeDisp, AWGRecLength
12209 
12210  try:
12211  AWGBFreqvalue = float(eval(AWGBFreqEntry.get()))
12212  except:
12213  AWGBFreqEntry.delete(0,"end")
12214  AWGBFreqEntry.insert(0, AWGBFreqvalue)
12215  if AWG_2X.get() == 2:
12216  if BodeScreenStatus.get() > 0 and BodeDisp.get() > 0:
12217  if AWGBFreqvalue > 90000: # max freq is 90KHz for Bode plotting
12218  AWGBFreqvalue = 90000
12219  AWGBFreqEntry.delete(0,"end")
12220  AWGBFreqEntry.insert(0, AWGBFreqvalue)
12221  else:
12222  if AWGBFreqvalue > 50000: # max freq is 50KHz
12223  AWGBFreqvalue = 50000
12224  AWGBFreqEntry.delete(0,"end")
12225  AWGBFreqEntry.insert(0, AWGBFreqvalue)
12226  else:
12227  if AWGBFreqvalue > 25000: # max freq is 25KHz
12228  AWGBFreqvalue = 25000
12229  AWGBFreqEntry.delete(0,"end")
12230  AWGBFreqEntry.insert(0, AWGBFreqvalue)
12231  if AWGBFreqvalue < 4.0:
12232  AWGRecLength = 32768*2
12233  else:
12234  AWGRecLength = 32768
12235  if AWGBFreqvalue < 0: # Set negative frequency entry to 0
12236  AWGBFreqvalue = 10
12237  AWGBFreqEntry.delete(0,"end")
12238  AWGBFreqEntry.insert(0, AWGBFreqvalue)
12239  # UpdateAWGB()
12240 
12241 def ToggleAWGBPhaseDelay():
12242  global AWGBPhaseDelay, phaseblab, awgbph, awgbdel
12243 
12244  if AWGBPhaseDelay.get() == 1:
12245  AWGBPhaseDelay.set(0)
12246  awgbph.configure(text="Phase")
12247  phaseblab.configure(text="Deg")
12248  elif AWGBPhaseDelay.get() == 0:
12249  AWGBPhaseDelay.set(1)
12250  awgbph.configure(text="Delay")
12251  phaseblab.configure(text="mSec")
12252 
12253 def BAWGBPhaseDelay():
12254  global AWGBPhaseDelay, phaseblab, awgbph, awgbdel
12255 
12256  if AWGBPhaseDelay.get() == 0:
12257  phaseblab.configure(text="Deg")
12258  awgbph.configure(text="Phase")
12259  elif AWGBPhaseDelay.get() == 1:
12260  phaseblab.configure(text="mSec")
12261  awgbph.configure(text="Delay")
12262 
12263 def BAWGBPhase(temp):
12264  global AWGBPhaseEntry, AWGBPhasevalue
12265 
12266  try:
12267  AWGBPhasevalue = float(eval(AWGBPhaseEntry.get()))
12268  except:
12269  AWGBPhaseEntry.delete(0,"end")
12270  AWGBPhaseEntry.insert(0, AWGBPhasevalue)
12271 
12272  if AWGBPhasevalue > 360: # max phase is 360 degrees
12273  AWGBPhasevalue = 360
12274  AWGBPhaseEntry.delete(0,"end")
12275  AWGBPhaseEntry.insert(0, AWGBPhasevalue)
12276  if AWGBPhasevalue < 0: # min phase is 0 degrees
12277  AWGBPhasevalue = 0
12278  AWGBPhaseEntry.delete(0,"end")
12279  AWGBPhaseEntry.insert(0, AWGBPhasevalue)
12280 
12281 def BAWGBDutyCycle(temp):
12282  global AWGBDutyCycleEntry, AWGBDutyCyclevalue
12283 
12284  try:
12285  AWGBDutyCyclevalue = float(eval(AWGBDutyCycleEntry.get()))/100
12286  except:
12287  AWGBDutyCycleEntry.delete(0,"end")
12288  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue)
12289 
12290  if AWGBDutyCyclevalue > 1: # max duty cycle is 100%
12291  AWGBDutyCyclevalue = 1
12292  AWGBDutyCycleEntry.delete(0,"end")
12293  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue*100)
12294  if AWGBDutyCyclevalue < 0: # min duty cycle is 0%
12295  AWGBDutyCyclevalue = 0
12296  AWGBDutyCycleEntry.delete(0,"end")
12297  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue)
12298  # UpdateAWGB()
12299 
12300 def BAWGBShape():
12301  global AWGBShape, AWGBWave, duty2lab, AWG_2X, CHA, CHB
12302 
12303  if AWGBShape.get() == 0:
12304  AWGBWave = 'dc'
12305  duty2lab.config(text="%")
12306  BAWGBPhaseDelay()
12307  if AWGBShape.get() == 1:
12308  AWGBWave = 'sine'
12309  duty2lab.config(text="%")
12310  BAWGBPhaseDelay()
12311  if AWGBShape.get() == 2:
12312  AWGBWave = 'triangle'
12313  duty2lab.config(text="%")
12314  BAWGBPhaseDelay()
12315  if AWGBShape.get() == 3:
12316  AWGBWave = 'sawtooth'
12317  duty2lab.config(text="%")
12318  BAWGBPhaseDelay()
12319  if AWGBShape.get() == 4:
12320  AWGBWave = 'square'
12321  duty2lab.config(text="%")
12322  BAWGBPhaseDelay()
12323  if AWGBShape.get() == 5:
12324  AWGBWave = 'stairstep'
12325  duty2lab.config(text="%")
12326  BAWGBPhaseDelay()
12327  if AWGBShape.get() > 5:
12328  AWGBWave = 'arbitrary'
12329  if AWG_2X.get() == 1:
12330  CHB.mode = CHA.mode
12331  AWGBWave = 'arbitrary'
12332  # UpdateAWGB()
12333 
12334 def AWGBReadFile():
12335  global AWGBwaveform, AWGBLength, awgwindow, AWG_2X, AWGB2X, AWGBcsvFile
12336 
12337  # Read values from CVS file
12338  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=awgwindow)
12339  AWGBcsvFile = filename
12340  AWGBLoadCSV()
12341 #
12342 def AWGBLoadCSV():
12343  global AWGBwaveform, AWGBLength, awgwindow, AWG_2X, AWGB2X, AWGBcsvFile, AWGBOffsetvalue
12344 
12345  BAWGBOffset(0)
12346  try:
12347  CSVFile = open(AWGBcsvFile)
12348  # dialect = csv.Sniffer().sniff(CSVFile.read(128), delimiters=None)
12349  CSVFile.seek(0)
12350  #csv_f = csv.reader(CSVFile, dialect)
12351  csv_f = csv.reader(CSVFile, csv.excel)
12352  except:
12353  showwarning("WARNING","No such file found or wrong format!", parent=awgwindow)
12354  AWGBwaveform = []
12355  ColumnNum = 0
12356  ColumnSel = 0
12357  RowNum = 0
12358  for row in csv_f:
12359  if len(row) > 1 and ColumnSel == 0:
12360  RequestColumn = askstring("Which Column?", "File contains 1 to " + str(len(row)) + " columns\n\nEnter column number to import:\n", initialvalue=1, parent=awgwindow)
12361  ColumnNum = int(RequestColumn) - 1
12362  ColumnLen = str(len(row))
12363  ColumnSel = 1
12364  try:
12365  colnum = 0
12366  for col in row:
12367  if colnum == ColumnNum:
12368  AWGBwaveform.append(float(col))
12369  colnum += 1
12370  except:
12371  print( 'skipping non-numeric row', RowNum)
12372  RowNum += 1
12373  AWGBwaveform = numpy.array(AWGBwaveform)
12374  AWGBwaveform = AWGBwaveform + AWGBOffsetvalue # add DC offset from Max entry
12376  CSVFile.close()
12377  UpdateAwgCont()
12378 
12379 # Split 2X sampled AWGBwaveform array into odd and even sample arrays
12380 def SplitAWGBwaveform():
12381  global AWG_2X, AWGB2X, AWGBwaveform
12382  global AWGFiltB, AWGFiltBCoef
12383 
12384  # check if AWG digital filter box checked
12385  if AWGFiltB.get() == 1:
12386  BufLen = len(AWGBwaveform)
12387  CoefLen = len(AWGFiltBCoef)/2
12388  AWGBwaveform = numpy.pad(AWGBwaveform, (CoefLen,CoefLen), 'wrap')
12389  AWGBwaveform = numpy.convolve(AWGBwaveform, AWGFiltBCoef)
12390  AWGBwaveform = numpy.roll(AWGBwaveform, -CoefLen)
12391  AWGBwaveform = AWGBwaveform[CoefLen:BufLen+CoefLen]
12392 
12393  if AWG_2X.get() == 2:
12394  Tempwaveform = []
12395  AWGB2X = []
12396  AWGB2X = AWGBwaveform[::2] # even numbered samples
12397  Tempwaveform = AWGBwaveform[1::2] # odd numbered samples Tempwaveform
12398  AWGBwaveform = Tempwaveform
12399 #
12400 def AWGBReadWAV():
12401  global AWGBwaveform, AWGBLength, awgwindow, AWGBwavFile
12402  global AWG_2X, AWGA2X
12403 
12404 # Read values from WAV file
12405  filename = askopenfilename(defaultextension = ".wav", filetypes=[("WAV files", "*.wav")], parent=awgwindow)
12406  AWGBwavFile = filename
12407  AWGBLoadWAV()
12408 #
12409 def AWGBLoadWAV():
12410  global AWGBwaveform, AWGBLength, awgwindow, AWGBwavFile
12411  global AWG_2X, AWGA2X
12412 
12413  try:
12414  spf = wave.open(AWGBwavFile,'r')
12415  except:
12416  showwarning("WARNING","No such file found or wrong format!", parent=awgwindow)
12417  AWGBwaveform = []
12418  #If Stereo
12419  if spf.getnchannels() == 2:
12420  showwarning("WARNING","Only mono files supported!", parent=awgwindow)
12421  return()
12422  #Extract Raw Audio from Wav File
12423  Length = spf.getnframes()
12424  if Length > 90000: # limit to first 90K samples
12425  Length = 90000
12426  signal = spf.readframes(Length)
12427  WAVsignal = numpy.fromstring(signal, 'Int16') # convert strings to Int
12428  # offset and scale for 0 5 V range
12429  AWGBwaveform = (WAVsignal * 2.5 / 32768) + 2.5
12430  AWGBwaveform = numpy.array(AWGBwaveform)
12432  spf.close()
12433  UpdateAwgCont()
12434 
12435 def AWGBWriteFile():
12436  global AWGBwaveform, AWGBLength, awgwindow
12437 
12438  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=awgwindow)
12439  numpy.savetxt(filename, AWGBwaveform, delimiter=",", fmt='%2.4f')
12440 
12441 def AWGBMakeMath():
12442  global AWGAwaveform, AWGSAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB
12443  global AWGBwaveform, VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGBMathString
12444  global FFTBuffA, FFTBuffB, FFTwindowshape, AWGBLength, awgwindow
12445  global DFiltACoef, DFiltBCoef, AWGBShapeLabel, AWGBLength
12446  global AWG_2X, AWGA2X
12447 
12448  TempString = AWGBMathString
12449  AWGBShapeLabel.config(text = "Math" ) # change displayed value
12450  AWGBMathString = askstring("AWG B Math Formula", "Current Formula: " + AWGBMathString + "\n\nNew Formula:\n", initialvalue=AWGBMathString, parent=awgwindow)
12451  if (AWGBMathString == None): # If Cancel pressed, then None
12452  AWGBMathString = TempString
12453  return
12454  try:
12455  AWGBwaveform = eval(AWGBMathString)
12456  except:
12457  showwarning("Syntax Error","Syntax Error in entered string!", parent=awgwindow)
12458  AWGBwaveform = numpy.array(AWGBwaveform)
12460  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
12461  UpdateAwgCont()
12462 #
12463 def AWGBConfigMath():
12464  global AWGAwaveform, AWGSAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB
12465  global AWGBwaveform, VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGBMathString
12466  global FFTBuffA, FFTBuffB, FFTwindowshape, AWGBLength, awgwindow
12467  global DFiltACoef, DFiltBCoef, AWGBShapeLabel
12468  global AWG_2X, AWGA2X
12469 
12470  AWGBwaveform = eval(AWGBMathString)
12471  AWGBwaveform = numpy.array(AWGBwaveform)
12473  UpdateAwgCont()
12474 #
12475 def AWGBMakeFourier():
12476  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBFreqvalue, awgwindow
12477  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12478  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, duty2lab
12479  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12480 
12481  Max_term = int(AWGBDutyCyclevalue*100)
12482 
12483  BAWGBAmpl(0)
12484  BAWGBOffset(0)
12485  BAWGBFreq(0)
12486  if AWG_2X.get() == 1:
12487  TempRate = (BaseSampleRate*2)
12488  else:
12489  TempRate = BaseSampleRate
12490  AWGBwaveform = []
12491  AWGBwaveform = numpy.cos(numpy.linspace(0, 2*numpy.pi, int(TempRate/AWGBFreqvalue))) # the fundamental
12492  k = 3
12493  while k <= Max_term:
12494  # Add odd harmonics up to max_term
12495  Harmonic = (math.sin(k*numpy.pi/2)/k)*(numpy.cos(numpy.linspace(0, k*2*numpy.pi, int(TempRate/AWGBFreqvalue))))
12496  AWGBwaveform = AWGBwaveform + Harmonic
12497  k = k + 2 # skip even numbers
12498  if AWG_Amp_Mode.get() == 0:
12499  amplitude = (AWGBOffsetvalue-AWGBAmplvalue)/2
12500  offset = (AWGBOffsetvalue+AWGBAmplvalue)/2
12501  else:
12502  amplitude = AWGBAmplvalue*AWGB_Ext_Gain.get()
12503  offset = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get()
12504  AWGBwaveform = (AWGBwaveform * amplitude) + offset # scale and offset the waveform
12506  duty2lab.config(text="Harmonics")
12507  BAWGBPhaseDelay()
12508  UpdateAwgCont()
12509 #
12510 def AWGBMakeBodeSine():
12511  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBperiodvalue
12512  global AWGBDutyCyclevalue, AWGBFreqvalue, duty2lab, AWGBgain, AWGBoffset, AWGBPhaseDelay, AWGBMode
12513  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate, AWG_Amp_Mode
12514  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset, AWGRecLength
12515 
12516  BAWGBAmpl(0)
12517  BAWGBOffset(0)
12518  BAWGBFreq(0)
12519  BAWGBPhase(0)
12520  BAWGBDutyCycle(0)
12521  MinFreq = float(AWGSAMPLErate)/float(AWGRecLength)
12522  if AWGBFreqvalue < MinFreq: # if frequency is less than 1 cycle in record length Hz use libsmu sine function
12523  AWGBShape.set(1)
12524  BAWGBShape()
12525  UpdateAwgCont()
12526  return
12527 
12528  if AWGBFreqvalue > 0.0:
12529  if AWG_2X.get() == 2:
12530  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12531  else:
12532  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12533  else:
12534  AWGBperiodvalue = 10.0
12535 
12536  if AWGBPhaseDelay.get() == 0:
12537  if AWGBPhasevalue > 0:
12538  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
12539  else:
12540  AWGBdelayvalue = 0.0
12541  elif AWGBPhaseDelay.get() == 1:
12542  AWGBdelayvalue = AWGBPhasevalue * AWGSAMPLErate / 1000
12543  Cycles = int(AWGRecLength/AWGBperiodvalue)
12544  if Cycles < 1:
12545  Cycles = 1
12546  RecLength = int(Cycles * AWGBperiodvalue)
12547  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
12548  RecLength = RecLength + 1
12549  AWGBwaveform = []
12550  AWGBwaveform = numpy.cos(numpy.linspace(0, 2*Cycles*numpy.pi, RecLength))
12551 
12552  if AWG_Amp_Mode.get() == 0:
12553  if AWGBMode.get() == 1: # convert to mA
12554  amplitude = (AWGBOffsetvalue-AWGBAmplvalue) / -2000.0
12555  offset = (AWGBOffsetvalue+AWGBAmplvalue) / 2000.0
12556  else:
12557  amplitude = (AWGBOffsetvalue-AWGBAmplvalue) / -2.0
12558  offset = (AWGBOffsetvalue+AWGBAmplvalue) / 2.0
12559  else:
12560  if AWGBMode.get() == 1: # convert to mA
12561  amplitude = AWGBAmplvalue/1000.0
12562  offset = AWGBOffsetvalue/1000.0
12563  else:
12564  amplitude = AWGBAmplvalue*AWGB_Ext_Gain.get()
12565  offset = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get()
12566  AWGBwaveform = (AWGBwaveform * amplitude) + offset # scale and offset the waveform
12567  AWGBwaveform = numpy.roll(AWGBwaveform, int(AWGBdelayvalue))
12568  #
12569  if AWG_2X.get() == 2:
12570  Tempwaveform = []
12571  AWGB2X = []
12572  AWGB2X = AWGBwaveform[::2] # even numbered samples
12573  Tempwaveform = AWGBwaveform[1::2] # odd numbered samples Tempwaveform
12574  AWGBwaveform = Tempwaveform
12575  BAWGBPhaseDelay()
12576  duty2lab.config(text="%")
12577  UpdateAwgCont()
12578 #
12580  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBperiodvalue
12581  global AWGBDutyCyclevalue, AWGBFreqvalue, duty2lab, AWGBgain, AWGBoffset, AWGBPhaseDelay, AWGBMode
12582  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate, AWG_Amp_Mode
12583  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset, AWGRecLength
12584 
12585  BAWGBAmpl(0)
12586  BAWGBOffset(0)
12587  BAWGBFreq(0)
12588  BAWGBPhase(0)
12589  BAWGBDutyCycle(0)
12590  MinFreq = float(AWGSAMPLErate)/float(AWGRecLength)
12591  if AWGBFreqvalue < MinFreq: # if frequency is less than 1 cycle in record length Hz use libsmu sine function
12592  AWGBShape.set(1)
12593  BAWGBShape()
12594  UpdateAwgCont()
12595  return
12596 
12597  if AWGBFreqvalue > 0.0:
12598  if AWG_2X.get() == 2:
12599  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12600  else:
12601  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12602  else:
12603  AWGBperiodvalue = 10.0
12604 
12605  if AWGBPhaseDelay.get() == 0:
12606  if AWGBPhasevalue > 0:
12607  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
12608  else:
12609  AWGBdelayvalue = 0.0
12610  elif AWGBPhaseDelay.get() == 1:
12611  AWGBdelayvalue = AWGBPhasevalue * AWGSAMPLErate / 1000
12612  Cycles = int(AWGRecLength/AWGBperiodvalue)
12613  if Cycles < 1:
12614  Cycles = 1
12615  RecLength = int(Cycles * AWGBperiodvalue)
12616  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
12617  RecLength = RecLength + 1
12618  AWGBwaveform = []
12619  AWGBwaveform = numpy.cos(numpy.linspace(0, 2*Cycles*numpy.pi, RecLength))
12620  AWGBwaveform = numpy.absolute(AWGBwaveform) * -1.0
12621  AWGBwaveform = AWGBwaveform + 0.5
12622  AWGBwaveform = AWGBwaveform * 2.0
12623  if AWG_Amp_Mode.get() == 0:
12624  if AWGBMode.get() == 1: # convert to mA
12625  amplitude = (AWGBOffsetvalue-AWGBAmplvalue) / -2000.0
12626  offset = (AWGBOffsetvalue+AWGBAmplvalue) / 2000.0
12627  else:
12628  amplitude = (AWGBOffsetvalue-AWGBAmplvalue) / -2.0
12629  offset = (AWGBOffsetvalue+AWGBAmplvalue) / 2.0
12630  else:
12631  if AWGBMode.get() == 1: # convert to mA
12632  amplitude = AWGBAmplvalue/1000.0
12633  offset = AWGBOffsetvalue/1000.0
12634  else:
12635  amplitude = AWGBAmplvalue*AWGB_Ext_Gain.get()
12636  offset = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get()
12637  AWGBwaveform = (AWGBwaveform * amplitude) + offset # scale and offset the waveform
12638  AWGBwaveform = numpy.roll(AWGBwaveform, int(AWGBdelayvalue))
12639  #
12640  if AWG_2X.get() == 2:
12641  Tempwaveform = []
12642  AWGB2X = []
12643  AWGB2X = AWGBwaveform[::2] # even numbered samples
12644  Tempwaveform = AWGBwaveform[1::2] # odd numbered samples Tempwaveform
12645  AWGBwaveform = Tempwaveform
12646  BAWGBPhaseDelay()
12647  duty2lab.config(text="%")
12648  UpdateAwgCont()
12649 #
12651  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBperiodvalue
12652  global AWGBDutyCyclevalue, AWGBFreqvalue, duty2lab, AWGBgain, AWGBoffset, AWGBPhaseDelay, AWGBMode
12653  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate, AWG_Amp_Mode
12654  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset, AWGRecLength
12655 
12656  BAWGBAmpl(0)
12657  BAWGBOffset(0)
12658  BAWGBFreq(0)
12659  BAWGBPhase(0)
12660  BAWGBDutyCycle(0)
12661  MinFreq = float(AWGSAMPLErate)/float(AWGRecLength)
12662  if AWGBFreqvalue < MinFreq: # if frequency is less than 1 cycle in record length Hz use libsmu sine function
12663  AWGBShape.set(1)
12664  BAWGBShape()
12665  UpdateAwgCont()
12666  return
12667 
12668  if AWGBFreqvalue > 0.0:
12669  if AWG_2X.get() == 2:
12670  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12671  else:
12672  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12673  else:
12674  AWGBperiodvalue = 10.0
12675 
12676  if AWGBPhaseDelay.get() == 0:
12677  if AWGBPhasevalue > 0:
12678  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
12679  else:
12680  AWGBdelayvalue = 0.0
12681  elif AWGBPhaseDelay.get() == 1:
12682  AWGBdelayvalue = AWGBPhasevalue * AWGSAMPLErate / 1000
12683  Cycles = int(AWGRecLength/AWGBperiodvalue)
12684  if Cycles < 1:
12685  Cycles = 1
12686  RecLength = int(Cycles * AWGBperiodvalue)
12687  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
12688  RecLength = RecLength + 1
12689  AWGBwaveform = []
12690  AWGBwaveform = numpy.cos(numpy.linspace(0, 2*Cycles*numpy.pi, RecLength))
12691  AWGBwaveform = numpy.minimum(AWGBwaveform, numpy.zeros(RecLength))
12692  AWGBwaveform = AWGBwaveform + 0.5
12693  AWGBwaveform = AWGBwaveform * 2.0
12694  if AWG_Amp_Mode.get() == 0:
12695  if AWGBMode.get() == 1: # convert to mA
12696  amplitude = (AWGBOffsetvalue-AWGBAmplvalue) / -2000.0
12697  offset = (AWGBOffsetvalue+AWGBAmplvalue) / 2000.0
12698  else:
12699  amplitude = (AWGBOffsetvalue-AWGBAmplvalue) / -2.0
12700  offset = (AWGBOffsetvalue+AWGBAmplvalue) / 2.0
12701  else:
12702  if AWGBMode.get() == 1: # convert to mA
12703  amplitude = AWGBAmplvalue/1000.0
12704  offset = AWGBOffsetvalue/1000.0
12705  else:
12706  amplitude = AWGBAmplvalue*AWGB_Ext_Gain.get()
12707  offset = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get()
12708  AWGBwaveform = (AWGBwaveform * amplitude) + offset # scale and offset the waveform
12709  AWGBwaveform = numpy.roll(AWGBwaveform, int(AWGBdelayvalue))
12710  #
12711  if AWG_2X.get() == 2:
12712  Tempwaveform = []
12713  AWGB2X = []
12714  AWGB2X = AWGBwaveform[::2] # even numbered samples
12715  Tempwaveform = AWGBwaveform[1::2] # odd numbered samples Tempwaveform
12716  AWGBwaveform = Tempwaveform
12717  BAWGBPhaseDelay()
12718  duty2lab.config(text="%")
12719  UpdateAwgCont()
12720 #
12721 def AWGBMakePWMSine():
12722  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength
12723  global AWGBDutyCyclevalue, AWGBFreqvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12724  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
12725  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12726 
12727  BAWGBAmpl(0)
12728  BAWGBOffset(0)
12729  BAWGBFreq(0)
12730  BAWGBPhase(0)
12731  BAWGBDutyCycle(0)
12732 
12733  if AWGBFreqvalue > 0.0:
12734  if AWG_2X.get() == 2:
12735  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12736  else:
12737  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12738  else:
12739  AWGBperiodvalue = 0.0
12740  if AWG_Amp_Mode.get() == 1:
12741  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12742  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12743  else:
12744  MaxV = AWGBOffsetvalue
12745  MinV = AWGBAmplvalue
12746 
12747  PulseWidth = int(AWGBDutyCyclevalue*100)
12748  PulseSamples = int(AWGBperiodvalue/PulseWidth)
12749  AWGBwaveform = []
12750  for i in range(PulseSamples): #(i = 0; i < cPulse; i++)
12751  v = round(PulseWidth/2*(1+numpy.sin(i*2*numpy.pi/PulseSamples)))
12752  # print(v)
12753  for j in range(PulseWidth): #(j = 0; j < cLength; j++)
12754  if j >= v:
12755  AWGBwaveform.append(MaxV) # j>=v?1:0
12756  else:
12757  AWGBwaveform.append(MinV) # j>=v?1:0
12759  duty2lab.config(text="PWidth")
12760  UpdateAwgCont()
12761 #
12762 def AWGBMakeSinc():
12763  global AWGBwaveform, AWGSampleRate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBperiodvalue
12764  global AWGBDutyCyclevalue, AWGBFreqvalue, duty2lab, AWGBgain, AWGBoffset, AWGBPhaseDelay
12765  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12766  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12767 
12768  BAWGBAmpl(0)
12769  BAWGBOffset(0)
12770  BAWGBFreq(0)
12771  BAWGBPhase(0)
12772  BAWGBDutyCycle(0)
12773 
12774  if AWGBFreqvalue > 0.0:
12775  if AWG_2X.get() == 1:
12776  AWGBperiodvalue = int((BaseSampleRate*2)/AWGBFreqvalue)
12777  if AWGBperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
12778  AWGBperiodvalue = AWGBperiodvalue + 1
12779  else:
12780  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12781  else:
12782  AWGBperiodvalue = 0.0
12783  if AWG_Amp_Mode.get() == 1:
12784  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12785  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12786  else:
12787  MaxV = AWGBOffsetvalue
12788  MinV = AWGBAmplvalue
12789 
12790  if AWGBPhaseDelay.get() == 0:
12791  if AWGBPhasevalue > 0:
12792  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
12793  else:
12794  AWGBdelayvalue = 0.0
12795  elif AWGBPhaseDelay.get() == 1:
12796  AWGBdelayvalue = AWGBPhasevalue * SAMPLErate / 1000
12797 
12798  Cycles = int(AWGBDutyCyclevalue*100)
12799  NCycles = -1 * Cycles
12800  AWGBwaveform = []
12801  AWGBwaveform = numpy.sinc(numpy.linspace(NCycles, Cycles, int(SAMPLErate/AWGBFreqvalue)))
12802  amplitude = (MaxV-MinV) / 2.0
12803  offset = (MaxV+MinV) / 2.0
12804  AWGBwaveform = (AWGBwaveform * amplitude) + offset # scale and offset the waveform
12805  Cycles = int(37500/AWGBperiodvalue)
12806  if Cycles < 1:
12807  Cycles = 1
12808  if Cycles > 1:
12809  Extend = int((Cycles-1.0)*AWGBperiodvalue/2.0)
12810  AWGBwaveform = numpy.pad(AWGBwaveform, (Extend,Extend), 'wrap')
12811  AWGBwaveform = numpy.roll(AWGBwaveform, int(AWGBdelayvalue))
12813  duty2lab.config(text="Cycles")
12814  BAWGBPhaseDelay()
12815  UpdateAwgCont()
12816 #
12817 def AWGBMakeSSQ():
12818  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
12819  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
12820  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12821  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
12822  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
12823  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12824 
12825  BAWGBAmpl(0)
12826  BAWGBOffset(0)
12827  BAWGBFreq(0)
12828  BAWGBPhase(0)
12829  BAWGBDutyCycle(0)
12830 
12831  if AWGBFreqvalue > 0.0:
12832  if AWG_2X.get() == 2:
12833  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12834  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
12835  else:
12836  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12837  SamplesPermS = int(BaseSampleRate/1000) # 100
12838  else:
12839  AWGBperiodvalue = 0.0
12840  if AWG_Amp_Mode.get() == 1:
12841  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12842  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12843  else:
12844  MaxV = AWGBOffsetvalue
12845  MinV = AWGBAmplvalue
12846  AWGBwaveform = []
12847  SlopeValue = int(AWGBPhasevalue*SamplesPermS)
12848  if SlopeValue <= 0:
12849  SlopeValue = 1
12850  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue)
12851  if PulseWidth <=0:
12852  PulseWidth = 1
12853  Remainder = int((AWGBperiodvalue - PulseWidth - SlopeValue)/2)
12854  if Remainder <= 0:
12855  Remainder = 1
12856  PulseWidth = PulseWidth - SlopeValue
12857  if PulseWidth <=0:
12858  PulseWidth = 1
12859  StepAmp = (MaxV - MinV)/2
12860  StepOff = (MaxV + MinV)/2
12861  AWGBwaveform = StepAmp * (numpy.cos(numpy.linspace(0, 2*numpy.pi, SlopeValue*2))) + StepOff
12862  MidArray = numpy.ones(PulseWidth) * MinV
12863  AWGBwaveform = numpy.insert(AWGBwaveform, SlopeValue, MidArray)
12864  AWGBwaveform = numpy.pad(AWGBwaveform, (Remainder, Remainder), 'edge')
12865  if AWGBBurstFlag.get() == 1:
12866  TempOneCycle = AWGBwaveform
12867  for i in range(AWGBCycles-1):
12868  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
12869  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
12870  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
12872  duty2lab.config(text="%")
12873  phaseblab.config(text = "Rise Time")
12874  UpdateAwgCont()
12875 #
12876 def AWGBMakeTrapazoid():
12877  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
12878  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
12879  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12880  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
12881  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
12882  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12883 
12884  BAWGBAmpl(0)
12885  BAWGBOffset(0)
12886  BAWGBFreq(0)
12887  BAWGBPhase(0)
12888  BAWGBDutyCycle(0)
12889 
12890  if AWGBFreqvalue > 0.0:
12891  if AWG_2X.get() == 2:
12892  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12893  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
12894  else:
12895  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12896  SamplesPermS = int(BaseSampleRate/1000) # 100
12897  else:
12898  AWGBperiodvalue = 0.0
12899  if AWG_Amp_Mode.get() == 1:
12900  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12901  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12902  else:
12903  MaxV = AWGBOffsetvalue
12904  MinV = AWGBAmplvalue
12905  AWGBwaveform = []
12906  SlopeValue = int(AWGBPhasevalue*SamplesPermS) # convert mS to samples
12907  if SlopeValue <= 0:
12908  SlopeValue = 1
12909  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue)
12910  if PulseWidth <=0:
12911  PulseWidth = 1
12912  Remainder = int(AWGBperiodvalue - PulseWidth) - SlopeValue
12913  if Remainder <= 0:
12914  Remainder = 1
12915  PulseWidth = PulseWidth - SlopeValue
12916  if PulseWidth <=0:
12917  PulseWidth = 1
12918  StepValue = (MaxV - MinV) / SlopeValue
12919  SampleValue = MinV
12920  for i in range(SlopeValue):
12921  AWGBwaveform.append(SampleValue)
12922  SampleValue = SampleValue + StepValue
12923  for i in range(PulseWidth):
12924  AWGBwaveform.append(MaxV)
12925  for i in range(SlopeValue):
12926  AWGBwaveform.append(SampleValue)
12927  SampleValue = SampleValue - StepValue
12928  for i in range(Remainder):
12929  AWGBwaveform.append(MinV)
12930  if AWGBBurstFlag.get() == 1:
12931  TempOneCycle = AWGBwaveform
12932  for i in range(AWGBCycles-1):
12933  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
12934  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
12935  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
12937  duty2lab.config(text="%")
12938  phaseblab.config(text = "Rise Time")
12939  UpdateAwgCont()
12940 #
12941 def AWGBMakePulse():
12942  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
12943  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
12944  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12945  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
12946  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
12947  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12948 
12949  BAWGBAmpl(0)
12950  BAWGBOffset(0)
12951  BAWGBFreq(0)
12952  BAWGBPhase(0)
12953 
12954  try:
12955  AWGBDutyCyclevalue = float(eval(AWGBDutyCycleEntry.get()))
12956  except:
12957  AWGBDutyCycleEntry.delete(0,"end")
12958  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue)
12959 
12960  if AWGBFreqvalue > 0.0:
12961  if AWG_2X.get() == 2:
12962  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12963  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
12964  else:
12965  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12966  SamplesPermS = int(BaseSampleRate/1000) # 100
12967  else:
12968  AWGBperiodvalue = 0.0
12969  if AWG_Amp_Mode.get() == 1:
12970  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12971  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12972  else:
12973  MaxV = AWGBOffsetvalue
12974  MinV = AWGBAmplvalue
12975  AWGBwaveform = []
12976  SlopeValue = int(AWGBPhasevalue*SamplesPermS) # convert mS to samples
12977  if SlopeValue <= 0:
12978  SlopeValue = 1
12979  PulseWidth = int(AWGBDutyCyclevalue*SamplesPermS) # convert mS to samples
12980  if PulseWidth <=0:
12981  PulseWidth = 1
12982  Remainder = int(AWGBperiodvalue - PulseWidth) - SlopeValue
12983  if Remainder <= 0:
12984  Remainder = 1
12985  PulseWidth = PulseWidth - SlopeValue
12986  if PulseWidth <=0:
12987  PulseWidth = 1
12988  StepValue = (MaxV - MinV) / SlopeValue
12989  SampleValue = MinV
12990  for i in range(SlopeValue):
12991  AWGBwaveform.append(SampleValue)
12992  SampleValue = SampleValue + StepValue
12993  for i in range(PulseWidth):
12994  AWGBwaveform.append(MaxV)
12995  for i in range(SlopeValue):
12996  AWGBwaveform.append(SampleValue)
12997  SampleValue = SampleValue - StepValue
12998  for i in range(Remainder):
12999  AWGBwaveform.append(MinV)
13000  if AWGBBurstFlag.get() == 1:
13001  TempOneCycle = AWGBwaveform
13002  for i in range(AWGBCycles-1):
13003  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
13004  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
13005  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
13007  duty2lab.config(text="Width mS")
13008  phaseblab.config(text = "Rise Time")
13009  UpdateAwgCont()
13010 #
13011 def AWGBMakeRamp():
13012  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
13013  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
13014  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
13015  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
13016  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
13017  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
13018 
13019  BAWGBAmpl(0)
13020  BAWGBOffset(0)
13021  BAWGBFreq(0)
13022  BAWGBPhase(0)
13023  BAWGBDutyCycle(0)
13024 
13025  if AWGBFreqvalue > 0.0:
13026  if AWG_2X.get() == 2:
13027  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
13028  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
13029  else:
13030  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
13031  SamplesPermS = int(BaseSampleRate/1000) # 100
13032  else:
13033  AWGBperiodvalue = 0.0
13034  if AWG_Amp_Mode.get() == 1:
13035  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
13036  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
13037  else:
13038  MaxV = AWGBOffsetvalue
13039  MinV = AWGBAmplvalue
13040  AWGBwaveform = []
13041  SlopeValue = int(AWGBPhasevalue*SamplesPermS)
13042  if SlopeValue <= 0:
13043  SlopeValue = 1
13044  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue)
13045  if PulseWidth <=0:
13046  PulseWidth = 1
13047  Remainder = int(AWGBperiodvalue - PulseWidth)
13048  if Remainder <= 0:
13049  Remainder = 1
13050  PulseWidth = PulseWidth - SlopeValue
13051  if PulseWidth <=0:
13052  PulseWidth = 1
13053  StepValue = (MaxV - MinV) / SlopeValue
13054  SampleValue = MinV
13055  for i in range(SlopeValue):
13056  AWGBwaveform.append(SampleValue)
13057  SampleValue = SampleValue + StepValue
13058  for i in range(PulseWidth):
13059  AWGBwaveform.append(MaxV)
13060  for i in range(Remainder):
13061  AWGBwaveform.append(MinV)
13062  if AWGBBurstFlag.get() == 1:
13063  TempOneCycle = AWGBwaveform
13064  for i in range(AWGBCycles-1):
13065  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
13066  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
13067  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
13069  duty2lab.config(text="%")
13070  phaseblab.config(text = "Slope Time")
13071  UpdateAwgCont()
13072 #
13073 def AWGBMakeUpDownRamp():
13074  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
13075  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
13076  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
13077  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
13078  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
13079  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
13080 
13081  BAWGBAmpl(0)
13082  BAWGBOffset(0)
13083  BAWGBFreq(0)
13084  BAWGBPhase(0)
13085  BAWGBDutyCycle(0)
13086 
13087  if AWGBFreqvalue > 0.0:
13088  if AWG_2X.get() == 2:
13089  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
13090  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
13091  else:
13092  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
13093  SamplesPermS = int(BaseSampleRate/1000) # 100
13094  else:
13095  AWGBperiodvalue = 0.0
13096  if AWG_Amp_Mode.get() == 1:
13097  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
13098  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
13099  else:
13100  MaxV = AWGBOffsetvalue
13101  MinV = AWGBAmplvalue
13102  #
13103  if AWGBPhaseDelay.get() == 0:
13104  if AWGBPhasevalue > 0:
13105  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
13106  else:
13107  AWGBdelayvalue = 0.0
13108  elif AWGBPhaseDelay.get() == 1:
13109  AWGBdelayvalue = AWGBPhasevalue * AWGSAMPLErate / 1000
13110  #
13111  AWGBwaveform = []
13112  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue)
13113  if PulseWidth <=0:
13114  PulseWidth = 1
13115  Remainder = int(AWGBperiodvalue - PulseWidth)
13116  if Remainder <= 0:
13117  Remainder = 1
13118  UpStepValue = (MaxV - MinV) / PulseWidth
13119  DownStepValue = (MaxV - MinV) / Remainder
13120  SampleValue = MinV
13121  for i in range(PulseWidth):
13122  AWGBwaveform.append(SampleValue)
13123  SampleValue = SampleValue + UpStepValue
13124  for i in range(Remainder):
13125  AWGBwaveform.append(SampleValue)
13126  SampleValue = SampleValue - DownStepValue
13127  AWGBwaveform = numpy.roll(AWGBwaveform, int(AWGBdelayvalue))
13128  if AWGBBurstFlag.get() == 1:
13129  TempOneCycle = AWGBwaveform
13130  for i in range(AWGBCycles-1):
13131  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
13132  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
13133  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
13135  BAWGBPhaseDelay()
13136  duty2lab.config(text = "Symmetry")
13137  BAWGBPhaseDelay()
13138  UpdateAwgCont()
13139 #
13140 def AWGBMakeImpulse():
13141  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
13142  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
13143  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
13144  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
13145  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
13146  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
13147 
13148  BAWGBAmpl(0)
13149  BAWGBOffset(0)
13150  BAWGBFreq(0)
13151  BAWGBPhase(0)
13152  BAWGBDutyCycle(0)
13153 
13154  if AWGBFreqvalue > 0.0:
13155  if AWG_2X.get() == 2:
13156  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
13157  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
13158  else:
13159  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
13160  SamplesPermS = int(BaseSampleRate/1000) # 100
13161  else:
13162  AWGBperiodvalue = 0.0
13163  if AWG_Amp_Mode.get() == 1:
13164  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
13165  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
13166  else:
13167  MaxV = AWGBOffsetvalue
13168  MinV = AWGBAmplvalue
13169  AWGBwaveform = []
13170  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue / 2)
13171  if AWGBPhaseDelay.get() == 0:
13172  DelayValue = int(AWGBperiodvalue*(AWGBPhasevalue/360))
13173  elif AWGBPhaseDelay.get() == 1:
13174  DelayValue = int(AWGBPhasevalue*SamplesPermS)
13175  for i in range(DelayValue-PulseWidth):
13176  AWGBwaveform.append((MinV+MaxV)/2)
13177  for i in range(PulseWidth):
13178  AWGBwaveform.append(MaxV)
13179  for i in range(PulseWidth):
13180  AWGBwaveform.append(MinV)
13181  DelayValue = int(AWGBperiodvalue-DelayValue)
13182  for i in range(DelayValue-PulseWidth):
13183  AWGBwaveform.append((MinV+MaxV)/2)
13184  if AWGBBurstFlag.get() == 1:
13185  TempOneCycle = AWGBwaveform
13186  for i in range(AWGBCycles-1):
13187  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
13188  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
13189  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
13191  duty2lab.config(text = "Duty Cycle")
13192  BAWGBPhaseDelay()
13193  UpdateAwgCont()
13194 
13195 def AWGBMakeUUNoise():
13196  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBFreqvalue
13197  global AWGBLength, AWGBperiodvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
13198  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
13199  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
13200  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
13201 
13202  BAWGBAmpl(0)
13203  BAWGBOffset(0)
13204  BAWGBFreq(0)
13205 
13206  if AWGBFreqvalue > 0.0:
13207  if AWG_2X.get() == 2:
13208  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
13209  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
13210  else:
13211  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
13212  SamplesPermS = int(BaseSampleRate/1000) # 100
13213  else:
13214  AWGBperiodvalue = 0.0
13215 
13216  if AWGBAmplvalue > AWGBOffsetvalue:
13217  MinV = AWGBOffsetvalue
13218  MaxV = AWGBAmplvalue
13219  else:
13220  MaxV = AWGBOffsetvalue
13221  MinV = AWGBAmplvalue
13222  if AWG_Amp_Mode.get() == 1:
13223  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
13224  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
13225  AWGBwaveform = []
13226  AWGBwaveform = numpy.random.uniform(MinV, MaxV, int(AWGBperiodvalue))
13227  Mid = (MaxV+MinV)/2
13228  if AWGBBurstFlag.get() == 1:
13229  TempOneCycle = AWGBwaveform
13230  for i in range(AWGBCycles-1):
13231  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
13232  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
13233  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'constant', constant_values=(Mid))
13235  BAWGBPhaseDelay()
13236  UpdateAwgCont()
13237 
13238 def AWGBMakeUGNoise():
13239  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBFreqvalue
13240  global AWGBLength, AWGBperiodvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
13241  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
13242  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
13243  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
13244 
13245  BAWGBAmpl(0)
13246  BAWGBOffset(0)
13247  BAWGBFreq(0)
13248 
13249  if AWGBFreqvalue > 0.0:
13250  if AWG_2X.get() == 2:
13251  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
13252  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
13253  else:
13254  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
13255  SamplesPermS = int(BaseSampleRate/1000) # 100
13256  else:
13257  AWGBperiodvalue = 0.0
13258  if AWGBAmplvalue > AWGBOffsetvalue:
13259  MinV = AWGBOffsetvalue
13260  MaxV = AWGBAmplvalue
13261  else:
13262  MaxV = AWGBOffsetvalue
13263  MinV = AWGBAmplvalue
13264  if AWG_Amp_Mode.get() == 1:
13265  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
13266  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
13267  AWGBwaveform = []
13268  AWGBwaveform = numpy.random.normal((MinV+MaxV)/2, (MaxV-MinV)/3, int(AWGBperiodvalue))
13269  Mid = (MaxV+MinV)/2
13270  if AWGBBurstFlag.get() == 1:
13271  TempOneCycle = AWGBwaveform
13272  for i in range(AWGBCycles-1):
13273  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
13274  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
13275  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'constant', constant_values=(Mid))
13277  BAWGBPhaseDelay()
13278  UpdateAwgCont()
13279 
13280 def BAWGBModeLabel():
13281  global AWGBMode, AWGBIOMode, AWGBModeLabel, DevID, devx, DevOne, CHB, HWRevOne
13282  global EnableScopeOnly
13283 
13284  if AWGBMode.get() == 0: # Source Voltage measure current mode
13285  label_txt = "SVMI"
13286  elif AWGBMode.get() == 1: # Source current measure voltage mode
13287  label_txt = "SIMV"
13288  elif AWGBMode.get() == 2: # High impedance mode
13289  label_txt = "Hi-Z"
13290  if AWGBIOMode.get() > 0: # Split Input / Output mode
13291  if HWRevOne == "D":
13292  if AWGBMode.get() == 0:
13293  AWGBMode.set(1)
13294  CHB.set_mode('i') # channel must be in source current mode for rev D boards
13295  label_txt = "SIMV"
13296  label_txt = label_txt + " Split I/O"
13297  if EnableScopeOnly == 0:
13298  label_txt = label_txt + " Mode"
13299  AWGBModeLabel.config(text = label_txt ) # change displayed value
13300  ReMakeAWGwaves()
13301  #UpdateAwgCont()
13302 
13303 def UpdateAWGB():
13304  global AWGBAmplvalue, AWGBOffsetvalue, AWGA2X, AWG_2X
13305  global AWGBFreqvalue, AWGBPhasevalue, AWGBPhaseDelay
13306  global AWGBDutyCyclevalue, FSweepMode, AWGBRepeatFlag, AWGSync
13307  global AWGBWave, AWGBMode, AWGBTerm, AWGBwaveform, AWGBIOMode
13308  global CHA, CHB, AWGSAMPLErate, DevID, devx, HWRevOne
13309  global amp2lab, off2lab, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
13310  global AWGA2X, AWGB2X, AWGAWave, AWGARepeatFlag, EnableScopeOnly
13311  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
13312 
13313  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode, 1 = Amp/Offset
13314  amp2lab.config(text = "Min Ch B" ) # change displayed value
13315  off2lab.config(text = "Max Ch B" ) # change displayed value
13316  else:
13317  amp2lab.config(text = "Amp Ch B" )
13318  off2lab.config(text = "Off Ch B" )
13319 #
13320  if AWG_2X.get() == 1:
13321  AWGBWave = 'arbitrary'
13322  if AWGBFreqvalue > 0.0:
13323  AWGBperiodvalue = AWGSAMPLErate/AWGBFreqvalue
13324  else:
13325  AWGBperiodvalue = 0.0
13326 #
13327  if AWGBPhaseDelay.get() == 0:
13328  if AWGBWave == 'square':
13329  AWGBPhasevalue = AWGBPhasevalue + 270.0
13330  if AWGBPhasevalue > 359:
13331  AWGBPhasevalue = AWGBPhasevalue - 360
13332  if AWGBPhasevalue > 0:
13333  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
13334  else:
13335  AWGBdelayvalue = 0.0
13336  elif AWGBPhaseDelay.get() == 1:
13337  AWGBdelayvalue = AWGBPhasevalue * 100
13338 #
13339  if AWGBTerm.get() == 0: # Open termination
13340  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set 2.5 V switch to open
13341  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set GND switch to open
13342  elif AWGBTerm.get() == 1: # 50 Ohm termination to GND
13343  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set 2.5 V switch to open
13344  devx.ctrl_transfer( 0x40, 0x50, 38, 0, 0, 0, 100) # set GND switch to closed
13345  elif AWGBTerm.get() == 2: # 50 Ohm termination to +2.5 Volts
13346  devx.ctrl_transfer( 0x40, 0x50, 37, 0, 0, 0, 100) # set 2.5 V switch to closed
13347  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set GND switch to open
13348 
13349  if AWGBWave == 'dc':
13350  if AWG_2X.get() == 1:
13351  AWGBWave == 'arbitrary'
13352  CHB.arbitrary(AWGA2X, AWGARepeatFlag.get())
13353  else:
13354  if AWGBMode.get() == 0: # Source Voltage measure current mode
13355  if AWGBIOMode.get() == 0:
13356  CHB.mode = Mode.SVMI # Put CHB in SVMI mode
13357  else:
13358  CHB.mode = Mode.SVMI_SPLIT # Put CHB in SVMI split mode
13359  CHB.constant(AWGBOffsetvalue)
13360  if AWGBMode.get() == 1: # Source current measure Voltage mode
13361  if AWGBIOMode.get() == 0:
13362  CHB.mode = Mode.SIMV # Put CHB in SIMV mode
13363  else:
13364  CHB.mode = Mode.SIMV_SPLIT # Put CHB in SIMV split mode
13365  CHB.constant(AWGBOffsetvalue/1000)
13366  if AWGBMode.get() == 2: # Hi impedance mode
13367  if AWGBIOMode.get() == 0:
13368  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
13369  else:
13370  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
13371 #
13372  if AWGBIOMode.get() > 0: # Split Input / Output mode
13373  if HWRevOne == "D":
13374  AWGBMode.set(1)
13375  CHB.mode = Mode.SIMV_SPLIT # channel must be in source current mode
13376 #
13377  else:
13378  if AWGBMode.get() == 0: # Source Voltage measure current mode
13379  if AWGBIOMode.get() == 0:
13380  CHB.mode = Mode.SVMI # Put CHB in SVMI mode
13381  else:
13382  CHB.mode = Mode.SVMI_SPLIT # Put CHB in SVMI split mode
13383  if AWGBMode.get() == 1: # Source current measure Voltage mode
13384  if AWGBIOMode.get() == 0:
13385  CHB.mode = Mode.SIMV # Put CHB in SIMV mode
13386  else:
13387  CHB.mode = Mode.SIMV_SPLIT # Put CHB in SIMV split mode
13388  AWGBOffsetvalue = AWGBOffsetvalue/1000
13389  AWGBAmplvalue = AWGBAmplvalue/1000
13390  if AWGBMode.get() == 2: # Hi impedance mode
13391  if AWGBIOMode.get() == 0:
13392  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
13393  else:
13394  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
13395  else:
13396  if AWG_Amp_Mode.get() == 1:
13397  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
13398  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
13399  else:
13400  MaxV = AWGBOffsetvalue
13401  MinV = AWGBAmplvalue
13402  try: # keep going even if low level library returns an error
13403  if AWGBWave == 'sine':
13404  CHB.sine(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue)
13405  elif AWGBWave == 'triangle':
13406  CHB.triangle(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue)
13407  elif AWGBWave == 'sawtooth':
13408  CHB.sawtooth(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue)
13409  elif AWGBWave == 'square':
13410  CHB.square(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue, AWGBDutyCyclevalue)
13411  elif AWGBWave == 'stairstep':
13412  CHB.stairstep(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue)
13413  elif AWGBWave == 'arbitrary':
13414  if EnableScopeOnly == 0:
13415  AddAWGBNoise()
13416  if AWGSync.get() == 0:
13417  AWGBRepeatFlag.set(1)
13418  if AWG_2X.get() == 1:
13419  AWGBWave == 'arbitrary'
13420  CHB.arbitrary(AWGA2X, AWGARepeatFlag.get())
13421  else:
13422  CHB.arbitrary(AWGBwaveform, AWGBRepeatFlag.get()) # set repeat flag
13423  except:
13424  donothing()
13425  if AWGBIOMode.get() > 0: # Split Input / Output mode
13426  if HWRevOne == "D":
13427  AWGBMode.set(1)
13428  CHB.mode = Mode.SIMV_SPLIT # channel must be in source current mode
13429 #
13430 def AddAWGBNoise():
13431  global AWG_2X, AWGA2X, AWGBwaveform
13432  global AWGBNoiseEntry, AWGBsbnoise, AWGBNoisevalue
13433 
13434  if AWGBsbnoise.get() == "None":
13435  return
13436  else:
13437  try:
13438  AWGBNoisevalue = float(eval(AWGBNoiseEntry.get()))
13439  except:
13440  AWGBNoiseEntry.delete(0,"end")
13441  AWGBNoiseEntry.insert(0, AWGBNoisevalue)
13442  if AWGBNoisevalue == 0.0:
13443  return
13444  AWGBNoiseform = []
13445  if AWGBsbnoise.get() == "Gaussian":
13446  AWGBNoiseform = numpy.random.normal(0.0, abs((AWGBNoisevalue)/3), len(AWGBwaveform))
13447  else:
13448  AWGBNoiseform = numpy.random.uniform((-AWGBNoisevalue)/2, (AWGBNoisevalue)/2, len(AWGBwaveform))
13449  AWGBwaveform = AWGBwaveform + AWGBNoiseform
13450  if AWG_2X.get() == 2:
13451  if AWGBsbnoise.get() == "Gaussian":
13452  AWGBNoiseform = numpy.random.normal(0.0, abs((AWGBNoisevalue)/3), len(AWGA2X))
13453  else:
13454  AWGBNoiseform = numpy.random.uniform((-AWGBNoisevalue)/2, (AWGBNoisevalue)/2, len(AWGA2X))
13455  AWGA2X = AWGA2X + AWGBNoiseform
13456 #
13457 def UpdateAwgCont():
13458  global session, CHA, CHB, AWGSync
13459  # if running and in continuous streaming mode temp stop, flush buffer and restart to change AWG settings
13460  if (RUNstatus.get() == 1) and AWGSync.get() == 0:
13461  if session.continuous:
13462  session.end()
13463  BAWGEnab() # set-up new AWG settings
13464  time.sleep(0.01) # wait awhile here for some reason
13465  session.start(0)
13466 #
13467 def UpdateAwgContRet(temp):
13468  ReMakeAWGwaves()
13469 
13470 def BAWGEnab():
13471  global AWGAMode, AWGBMode, AWGSync
13472  global CHA, CHB, discontloop, contloop, session
13473 
13474  # Stream = False
13475  # print "Updateing AWGs"
13476  BAWGAAmpl(0)
13477  BAWGAOffset(0)
13478  BAWGAFreq(0)
13479  BAWGAPhase(0)
13480  BAWGADutyCycle(0)
13481  BAWGAShape()
13482  BAWGBAmpl(0)
13483  BAWGBOffset(0)
13484  BAWGBFreq(0)
13485  BAWGBPhase(0)
13486  BAWGBDutyCycle(0)
13487  BAWGBShape()
13488  UpdateAWGA()
13489  UpdateAWGB()
13490 
13491 def BAWGSync():
13492  global RUNstatus, AWGSync, session, CHA, CHB, IAScreenStatus, IADisp
13493 
13494  if (RUNstatus.get() == 1): # do this only if running
13495  if IAScreenStatus.get() > 0 and IADisp.get() > 0:
13496  AWGSync.set(1)
13497  return
13498  if AWGSync.get() == 0:
13499  #UpdateAwgCont()
13500  session.flush()
13501  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z mode
13502  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z mode
13503  BAWGEnab()
13504  session.start(0)
13505  time.sleep(0.02) # wait awhile here for some reason
13506  elif session.continuous:
13507  session.end()
13508  session.flush()
13509  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z mode
13510  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z mode
13511 
13512 # ======= Spectrum Analyzer functions ===========
13513 #
13514 def BSaveScreenSA():
13515  global CANVASwidthF, CANVASheightF, freqwindow
13516  global COLORtext
13517  # ask for file name
13518  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")], parent=freqwindow)
13519  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n", parent=freqwindow)
13520  if MarkerNum > 0 or ColorMode.get() > 0:
13521  Freqca.postscript(file=filename, height=CANVASheightF, width=CANVASwidthF, colormode='color', rotate=Orient)
13522  else: # temp change text color to black
13523  COLORtext = "#000000"
13525  # save postscript file
13526  Freqca.postscript(file=filename, height=CANVASheightF, width=CANVASwidthF, colormode='color', rotate=Orient)
13527  #
13528  COLORtext = "#ffffff"
13530 #
13531 def Bnot():
13532  print( "Routine not made yet")
13533 
13534 def BShowCurvesAllSA():
13535  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P
13536  ShowC1_VdB.set(1)
13537  ShowC1_P.set(1)
13538  ShowC2_VdB.set(1)
13539  ShowC2_P.set(1)
13540 
13541 def BShowCurvesNoneSA():
13542  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P
13543  ShowC1_VdB.set(0)
13544  ShowC1_P.set(0)
13545  ShowC2_VdB.set(0)
13546  ShowC2_P.set(0)
13547 
13548 def BNormalmode():
13549  global RUNstatus
13550  global FreqTraceMode
13551 
13552  FreqTraceMode.set(1)
13553  if RUNstatus.get() == 0: # Update if stopped
13555  if RUNstatus.get() == 2: # Restart if running
13556  RUNstatus.set(4)
13557 
13558 def BPeakholdmode():
13559  global RUNstatus
13560  global FreqTraceMode
13561 
13562  FreqTraceMode.set(2)
13563  if RUNstatus.get() == 0: # Update if stopped
13565  if RUNstatus.get() == 2: # Restart if running
13566  RUNstatus.set(4)
13567 
13568 def BAveragemode():
13569  global RUNstatus, TRACEaverage, FreqTraceMode, freqwindow
13570 
13571  FreqTraceMode.set(3)
13572 
13573  if RUNstatus.get() == 0: # Update if stopped
13575  if RUNstatus.get() == 2: # Restart if running
13576  RUNstatus.set(4)
13577 
13578 def BResetFreqAvg():
13579  global FreqTraceMode, TRACEresetFreq
13580 
13581  if FreqTraceMode.get()==3:
13582  TRACEresetFreq = True
13583 
13584 def BSTOREtraceSA():
13585  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowMathSA
13586  global T1Fline, T2Fline, T1FRline, T2FRline, TFRMline, TFMline
13587  global T1Pline, T2Pline, T1PRline, T2PRline
13588  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
13589  global PeakxM, PeakyM, PeakMdb, PeakfreqM
13590  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
13591  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
13592  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM
13593 
13594  if ShowC1_VdB.get() == 1:
13595  T1FRline = T1Fline
13596  PeakxRA = PeakxA
13597  PeakyRA = PeakyA
13598  PeakdbRA = PeakdbA
13599  PeakfreqRA = PeakfreqA
13600  if ShowC2_VdB.get() == 1:
13601  T2FRline = T2Fline
13602  PeakxRB = PeakxB
13603  PeakyRB = PeakyB
13604  PeakdbRB = PeakdbB
13605  PeakfreqRB = PeakfreqB
13606  if ShowC1_P.get() == 1:
13607  T1PRline = T1Pline
13608  if ShowC2_P.get() == 1:
13609  T2PRline = T2Pline
13610  if ShowMathSA.get() > 0:
13611  TFRMline = TFMline
13612  PeakxRM = PeakxM
13613  PeakyRM = PeakyM
13614  PeakRMdb = PeakMdb
13615  PeakfreqRM = PeakfreqM
13616 
13617  UpdateFreqTrace() # Always Update
13618 #
13619 def BSTOREtraceBP():
13620  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, ShowMathBP
13621  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
13622  global TAFline, TBFline, TAFRline, TBFRline, TBPRMline, TBPMline
13623  global TAPline, TBPline, TAPRline, TBPRline
13624  global TIARline, TIAXline, TIAMagline, TIAAngline
13625  global RefIARline, RefIAXline, RefIAMagline, RefIAAngline
13626  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
13627  global PeakxM, PeakyM, PeakMdb, PeakfreqM
13628  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
13629  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
13630  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM
13631 
13632  if ShowCA_VdB.get() == 1:
13633  TAFRline = TAFline
13634  PeakxRA = PeakxA
13635  PeakyRA = PeakyA
13636  PeakdbRA = PeakdbA
13637  PeakfreqRA = PeakfreqA
13638  if ShowCB_VdB.get() == 1:
13639  TBFRline = TBFline
13640  PeakxRB = PeakxB
13641  PeakyRB = PeakyB
13642  PeakdbRB = PeakdbB
13643  PeakfreqRB = PeakfreqB
13644  if ShowCA_P.get() == 1:
13645  TAPRline = TAPline
13646  if ShowCB_P.get() == 1:
13647  TBPRline = TBPline
13648  if ShowMathBP.get() > 0:
13649  TBPRMline = TBPMline
13650  PeakxRM = PeakxM
13651  PeakyRM = PeakyM
13652  PeakRMdb = PeakMdb
13653  PeakfreqRM = PeakfreqM
13654  if Show_Rseries.get() > 0:
13655  RefIARline = TIARline
13656  if Show_Xseries.get() > 0:
13657  RefIAXline = TIAXline
13658  if Show_Magnitude.get() > 0:
13659  RefIAMagline = TIAMagline
13660  if Show_Angle.get() > 0:
13661  RefIAAngline = TIAAngline
13662  UpdateBodeTrace() # Always Update
13663 #
13664 def BCSVfile(): # Store the trace as CSV file [frequency, magnitude or dB value]
13665  global FSweepAdB, FSweepBdB, FSweepAPh, FSweepBPh, FStep, FBins, bodewindow
13666  global SAMPLErate, ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, TRACEsize
13667 
13668  # Set the TRACEsize variable
13669  if ShowCA_VdB.get() == 1:
13670  TRACEsize = len(FSweepAdB) # Set the trace length
13671  elif ShowCA_VdB.get() == 1:
13672  TRACEsize = len(FSweepBdB)
13673  if TRACEsize == 0: # If no trace, skip rest of this routine
13674  return()
13675 # ask if save as magnitude or dB
13676  dB = askyesno("Mag or dB: ","Save amplidude data as dB (Yes) or Mag (No):\n", parent=bodewindow)
13677 # Yes 1 = dB, No 0 = Mag
13678  # Make the file name and open it
13679  tme = strftime("%Y%b%d-%H%M%S", gmtime()) # The time
13680  filename = "Bode-" + tme
13681  filename = filename + ".csv"
13682  # open file to save data
13683  filename = asksaveasfilename(initialfile = filename, defaultextension = ".csv",
13684  filetypes=[("Comma Separated Values", "*.csv")], parent=bodewindow)
13685  DataFile = open(filename,'a') # Open output file
13686  HeaderString = 'Frequency-#, '
13687  if ShowCA_VdB.get() == 1:
13688  if dB == 1:
13689  HeaderString = HeaderString + 'CA-dB, '
13690  if dB == 0:
13691  HeaderString = HeaderString + 'CA-Mag, '
13692  if ShowCB_VdB.get() == 1:
13693  if dB == 1:
13694  HeaderString = HeaderString + 'CB-dB, '
13695  if dB == 0:
13696  HeaderString = HeaderString + 'CB-Mag, '
13697  if ShowCA_P.get() == 1:
13698  HeaderString = HeaderString + 'Phase A-B, '
13699  if ShowCB_P.get() == 1:
13700  HeaderString = HeaderString + 'Phase B-A, '
13701  HeaderString = HeaderString + '\n'
13702  DataFile.write( HeaderString )
13703 
13704  n = 0
13705  while n < len(FSweepAdB):
13706  F = FBins[FStep[n]] # look up frequency bin in list of bins
13707  txt = str(F)
13708  if ShowCA_VdB.get() == 1:
13709  V = 10 * math.log10(float(FSweepAdB[n]))
13710  if dB == 0:
13711  V = 10.0**(V/20.0)
13712  txt = txt + "," + str(V)
13713  if ShowCB_VdB.get() == 1:
13714  V = 10 * math.log10(float(FSweepBdB[n]))
13715  if dB == 0:
13716  V = 10.0**(V/20.0)
13717  txt = txt + "," + str(V)
13718  if ShowCA_P.get() == 1:
13719  RelPhase = FSweepAPh[n]#-FSweepBPh[n]
13720  if RelPhase > 180:
13721  RelPhase = RelPhase - 360
13722  elif RelPhase < -180:
13723  RelPhase = RelPhase + 360
13724  txt = txt + "," + str(RelPhase)
13725  if ShowCB_P.get() == 1:
13726  RelPhase = FSweepBPh[n]#-FSweepAPh[n]
13727  if RelPhase > 180:
13728  RelPhase = RelPhase - 360
13729  elif RelPhase < -180:
13730  RelPhase = RelPhase + 360
13731  txt = txt + "," + str(RelPhase)
13732  txt = txt + "\n"
13733  DataFile.write(txt)
13734  n = n + 1
13735 
13736  DataFile.close() # Close the file
13737 
13738 def BSaveDataIA():
13739  global iawindow, FStep, FBins
13740  global NetworkScreenStatus, NSweepSeriesR, NSweepSeriesX, NSweepSeriesMag, NSweepSeriesAng
13741 
13742  if NetworkScreenStatus.get() > 0:
13743  tme = strftime("%Y%b%d-%H%M%S", gmtime()) # The time
13744  filename = "Impedance-" + tme
13745  filename = filename + ".csv"
13746  # open file to save data
13747  filename = asksaveasfilename(initialfile = filename, defaultextension = ".csv",
13748  filetypes=[("Comma Separated Values", "*.csv")], parent=iawindow)
13749  DataFile = open(filename,'a') # Open output file
13750  HeaderString = 'Frequency, Series R, Series X, Series Z, Series Angle'
13751  HeaderString = HeaderString + '\n'
13752  DataFile.write( HeaderString )
13753 
13754  n = 0
13755  while n < len(NSweepSeriesR):
13756  F = FBins[int(FStep[n])] # look up frequency bin in list of bins
13757  txt = str(F) + "," + str(NSweepSeriesR[n]) + "," + str(NSweepSeriesX[n]) + "," + str(NSweepSeriesMag[n]) + "," + str(NSweepSeriesAng[n])
13758  txt = txt + "\n"
13759  DataFile.write(txt)
13760  n = n + 1
13761  DataFile.close() # Close the file
13762  else:
13763  return
13764 #
13765 def BStartSA():
13766  global RUNstatus, PowerStatus, devx, PwrBt, freqwindow, session, AWGSync, contloop, discontloop
13767  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowMathSA, DevID, FWRevOne, StopFreqEntry
13768  global Two_X_Sample, ADC_Mux_Mode, ShowAWGASA, ShowAWGBSA
13769 
13770  #AWGSync.set(0) # always run in continuous mode
13771  if DevID == "No Device":
13772  showwarning("WARNING","No Device Plugged In!")
13773  elif FWRevOne == 0.0:
13774  showwarning("WARNING","Out of data Firmware!")
13775  else:
13776  if PowerStatus == 0:
13777  PowerStatus = 1
13778  PwrBt.config(style="Pwr.TButton",text="PWR-On")
13779  devx.ctrl_transfer( 0x40, 0x51, 49, 0, 0, 0, 100) # turn on analog power
13780 
13781  if (ShowC1_VdB.get() == 0 and
13782  ShowC2_VdB.get() == 0 and
13783  ShowMathSA.get() == 0 and
13784  ShowAWGASA.get() == 0 and
13785  ShowAWGBSA.get() == 0 and
13786  ShowC1_P.get() == 0 and
13787  ShowC2_P.get() == 0):
13788  showwarning("WARNING","Select at least one trace first", parent=freqwindow)
13789  return()
13790  try:
13791  StopFrequency = float(StopFreqEntry.get())
13792  except:
13793  StopFreqEntry.delete(0,"end")
13794  StopFreqEntry.insert(0,50000)
13795  StopFrequency = 50000
13796  if FWRevOne > 2.16:
13797  if StopFrequency >= 50000:
13798  Two_X_Sample.set(1)
13799  else:
13800  Two_X_Sample.set(0)
13801  ADC_Mux_Mode.set(0)
13802  SetADC_Mux()
13803  #
13804  BStart()
13805 #
13806  UpdateFreqAll() # Always Update
13807 
13808 def BStopSA():
13809  global RUNstatus, session, AWGSync
13810 
13811  if (RUNstatus.get() == 1):
13812  RUNstatus.set(0)
13813  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
13814  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
13815  if AWGSync.get() == 0: # running in continuous mode
13816  CHA.constant(0.0)
13817  CHB.constant(0.0)
13818  # print "Stoping continuous mode"
13819  if session.continuous:
13820  # print "Stoping Is Continuous? ", session.continuous
13821  time.sleep(0.02)
13822  #print "Is Continuous? ", session.continuous
13823  else:
13824  contloop = 0
13825  discontloop = 1
13826  session.cancel()
13827  elif (RUNstatus.get() == 2):
13828  RUNstatus.set(3)
13829  elif (RUNstatus.get() == 3):
13830  RUNstatus.set(3)
13831  elif (RUNstatus.get() == 4):
13832  RUNstatus.set(3)
13833  UpdateFreqAll() # Always Update
13834 
13835 def Blevel1():
13836  global DBlevel
13837  global RUNstatus
13838 
13839  DBlevel.set(DBlevel.get() - 1)
13840 
13841  if RUNstatus.get() == 0: # Update if stopped
13842  UpdateFreqTrace()
13843 
13844 def Blevel2():
13845  global DBlevel
13846  global RUNstatus
13847 
13848  DBlevel.set(DBlevel.get() + 1)
13849 
13850  if RUNstatus.get() == 0: # Update if stopped
13851  UpdateFreqTrace()
13852 
13853 def Blevel3():
13854  global DBlevel
13855  global RUNstatus
13856 
13857  DBlevel.set(DBlevel.get() - 10)
13858 
13859  if RUNstatus.get() == 0: # Update if stopped
13860  UpdateFreqTrace()
13861 
13862 def Blevel4():
13863  global DBlevel
13864  global RUNstatus
13865 
13866  DBlevel.set(DBlevel.get() + 10)
13867 
13868  if RUNstatus.get() == 0: # Update if stopped
13869  UpdateFreqTrace()
13870 #
13871 def Bsamples1():
13872  global RUNstatus, SpectrumScreenStatus, IAScreenStatus
13873  global SMPfftpwrTwo, SMPfft, FFTwindow
13874  global TRACEresetFreq, PhAScreenStatus
13875 
13876  if FFTwindow.get() != 8:
13877  if (SMPfftpwrTwo.get() > 6): # Min 64
13878  SMPfftpwrTwo.set(SMPfftpwrTwo.get() - 1)
13879  TRACEresetFreq = True # Reset trace peak and trace average
13880  SMPfft = 2 ** int(SMPfftpwrTwo.get())
13881 
13882  if RUNstatus.get() == 0: # Update if stopped
13883  if SpectrumScreenStatus.get() > 0:
13885  if IAScreenStatus.get() > 0:
13886  UpdateIAScreen()
13887  if PhAScreenStatus.get() > 0:
13888  UpdatePhAScreen()
13889  if RUNstatus.get() == 2: # Restart if running
13890  RUNstatus.set(4)
13891 
13892 def Bsamples2():
13893  global RUNstatus, PhAScreenStatus
13894  global SMPfftpwrTwo, SMPfft, FFTwindow
13895  global TRACEresetFreq, SpectrumScreenStatus, IAScreenStatus
13896 
13897  if FFTwindow.get() != 8:
13898  if (SMPfftpwrTwo.get() < 16): # Max 65536
13899  SMPfftpwrTwo.set(SMPfftpwrTwo.get() + 1)
13900  TRACEresetFREQ = True # Reset trace peak and trace average
13901  SMPfft = 2 ** int(SMPfftpwrTwo.get())
13902 
13903  if RUNstatus.get() == 0: # Update if stopped
13904  if SpectrumScreenStatus.get() > 0:
13906  if IAScreenStatus.get() > 0:
13907  UpdateIAScreen()
13908  if PhAScreenStatus.get() > 0:
13909  UpdatePhAScreen()
13910  if RUNstatus.get() == 2: # Restart if running
13911  RUNstatus.set(4)
13912 
13913 def BDBdiv1():
13914  global DBdivindex
13915  global RUNstatus
13916 
13917  if (DBdivindex.get() >= 1):
13918  DBdivindex.set(DBdivindex.get() - 1)
13919 
13920  if RUNstatus.get() == 0: # Update if stopped
13921  UpdateFreqTrace()
13922 
13923 def BDBdiv2():
13924  global DBdivindex
13925  global DBdivlist
13926  global RUNstatus
13927 
13928  if (DBdivindex.get() < len(DBdivlist) - 1):
13929  DBdivindex.set(DBdivindex.get() + 1)
13930 
13931  if RUNstatus.get() == 0: # Update if stopped
13932  UpdateFreqTrace()
13933 #----- Bode Plot controls
13934 def BStartBP():
13935  global RUNstatus, LoopNum, PowerStatus, devx, PwrBt, bodewindow, session, AWGSync
13936  global ShowCA_VdB, ShowCB_P, ShowCB_VdB, ShowCB_P, ShowMathBP, contloop, discontloop
13937  global FBins, FStep, NSteps, FSweepMode, HScaleBP, CutDC
13938  global AWGAMode, AWGAShape, AWGBMode, AWGBShape
13939  global StartBodeEntry, StopBodeEntry, SweepStepBodeEntry, DevID, FWRevOne
13940  global AWGAFreqEntry, AWGBFreqEntry, Reset_Freq, AWGAIOMode, AWGBIOMode
13941  global Two_X_Sample, ADC_Mux_Mode, AWG_2X, ZEROstuffing, SAMPLErate
13942  global BeginIndex, EndIndex
13943 
13944  if DevID == "No Device":
13945  showwarning("WARNING","No Device Plugged In!")
13946  elif FWRevOne == 0.0:
13947  showwarning("WARNING","Out of data Firmware!")
13948  else:
13949  if PowerStatus == 0:
13950  PowerStatus = 1
13951  PwrBt.config(style="Pwr.TButton",text="PWR-On")
13952  devx.ctrl_transfer( 0x40, 0x51, 49, 0, 0, 0, 100) # turn on analog power
13953 
13954  if ShowCA_VdB.get() == 0 and ShowCB_VdB.get() == 0 and ShowMathBP.get() == 0:
13955  showwarning("WARNING","Select at least one trace first", parent=bodewindow)
13956  return()
13957  #
13958  if ZEROstuffing.get() < 3:
13959  ZEROstuffing.set(3)
13960  CutDC.set(1) # set to remove DC
13961  try:
13962  EndFreq = float(StopBodeEntry.get())
13963  except:
13964  StopBodeEntry.delete(0,"end")
13965  StopBodeEntry.insert(0,10000)
13966  EndFreq = 10000
13967  if FWRevOne > 2.16:
13968  if EndFreq >= 20000:
13969  Two_X_Sample.set(1)
13970  FBins = numpy.linspace(0, 100000, num=32768) #16384)
13971  else:
13972  Two_X_Sample.set(0)
13973  FBins = numpy.linspace(0, 50000, num=32768) #16384)
13974  ADC_Mux_Mode.set(0)
13975  SetADC_Mux()
13976  try:
13977  BeginFreq = float(StartBodeEntry.get())
13978  except:
13979  StartBodeEntry.delete(0,"end")
13980  StartBodeEntry.insert(0,100)
13981  BeginFreq = 100
13982  #
13983  if FSweepMode.get() == 1:
13984  if AWGAMode.get() == 2:
13985  AWGAMode.set(0) # Set AWG A to SVMI
13986  AWGAShape.set(18) # Set Shape to Sine
13987  if Two_X_Sample.get() == 1:
13988  AWGBIOMode.set(1)
13989  AWGBMode.set(0)
13990  else:
13991  AWGBMode.set(2) # Set AWG B to Hi-Z
13992  AWG_2X.set(0)
13993  BAWG2X()
13994  Reset_Freq = AWGAFreqEntry.get()
13995  if FSweepMode.get() == 2:
13996  if AWGBMode.get() == 2:
13997  AWGBMode.set(0) # Set AWG B to SVMI
13998  AWGBShape.set(18) # Set Shape to Sine
13999  if Two_X_Sample.get() == 1:
14000  AWGAIOMode.set(1)
14001  AWGAMode.set(0)
14002  else:
14003  AWGAMode.set(2) # Set AWG A to Hi-Z
14004  AWG_2X.set(0)
14005  BAWG2X()
14006  Reset_Freq = AWGBFreqEntry.get()
14007  if FSweepMode.get() == 3: # using external Minigen
14008  AWGAMode.set(2) # Set AWG A to Hi-Z
14009  AWGBMode.set(2) # Set AWG B to Hi-Z
14010  try:
14011  NSteps.set(float(SweepStepBodeEntry.get()))
14012  except:
14013  SweepStepBodeEntry.delete(0,"end")
14014  SweepStepBodeEntry.insert(0, NSteps.get())
14015  #
14016  if FSweepMode.get() > 0:
14017  BAWGAModeLabel() # make sure AWG screen labels reflect any changes to the modes
14018  BAWGBModeLabel()
14019  LoopNum.set(1)
14020  NyquistFreq = SAMPLErate/2
14021  BeginIndex = int((BeginFreq/NyquistFreq)*32768)#16384)
14022  EndIndex = int((EndFreq/NyquistFreq)*32768)#16384)
14023  if NSteps.get() < 5:
14024  NSteps.set(5)
14025  if HScaleBP.get() == 1:
14026  LogFStop = math.log10(EndIndex)
14027  try:
14028  LogFStart = math.log10(BeginIndex)
14029  except:
14030  LogFStart = 0.1
14031  FStep = numpy.logspace(LogFStart, LogFStop, num=NSteps.get(), base=10.0)
14032  else:
14033  FStep = numpy.linspace(BeginIndex, EndIndex, num=NSteps.get())
14034 
14035  BStart()
14036  # UpdateBodeAll() # Always Update
14037 #
14038 def BStopBP():
14039  global RUNstatus, session, AWGSync, FSweepMode, AWGAFreqEntry, AWGBFreqEntry, Reset_Freq
14040 
14041  if FSweepMode.get() == 1:
14042  AWGAFreqEntry.delete(0,"end")
14043  AWGAFreqEntry.insert(0, Reset_Freq)
14044  if FSweepMode.get() == 2:
14045  AWGBFreqEntry.delete(0,"end")
14046  AWGBFreqEntry.insert(0, Reset_Freq)
14047 #
14048  if (RUNstatus.get() == 1):
14049  RUNstatus.set(0)
14050  if AWGSync.get() == 0: # running in continuous mode
14051  session.cancel() # cancel continuous session mode while paused
14052  elif (RUNstatus.get() == 2):
14053  RUNstatus.set(3)
14054  elif (RUNstatus.get() == 3):
14055  RUNstatus.set(3)
14056  elif (RUNstatus.get() == 4):
14057  RUNstatus.set(3)
14058  UpdateBodeAll() # Always Update
14059 #
14060 def Blevel1BP():
14061  global DBlevelBP
14062  global RUNstatus
14063 
14064  DBlevelBP.set(DBlevelBP.get() - 1)
14065 
14066  if RUNstatus.get() == 0: # Update if stopped
14067  UpdateBodeTrace()
14068 
14069 def Blevel2BP():
14070  global DBlevelBP
14071  global RUNstatus
14072 
14073  DBlevelBP.set(DBlevelBP.get() + 1)
14074 
14075  if RUNstatus.get() == 0: # Update if stopped
14076  UpdateBodeTrace()
14077 
14078 def Blevel3BP():
14079  global DBlevelBP
14080  global RUNstatus
14081 
14082  DBlevelBP.set(DBlevelBP.get() - 10)
14083 
14084  if RUNstatus.get() == 0: # Update if stopped
14085  UpdateBodeTrace()
14086 
14087 def Blevel4BP():
14088  global DBlevelBP
14089  global RUNstatus
14090 
14091  DBlevelBP.set(DBlevelBP.get() + 10)
14092 
14093  if RUNstatus.get() == 0: # Update if stopped
14094  UpdateBodeTrace()
14095 
14096 def BDBdiv1BP():
14097  global DBdivindexBP
14098  global RUNstatus
14099 
14100  if (DBdivindexBP.get() >= 1):
14101  DBdivindexBP.set(DBdivindexBP.get() - 1)
14102 
14103  if RUNstatus.get() == 0: # Update if stopped
14104  UpdateBodeTrace()
14105 
14106 def BDBdiv2BP():
14107  global DBdivindexBP
14108  global DBdivlist
14109  global RUNstatus
14110 
14111  if (DBdivindexBP.get() < len(DBdivlist) - 1):
14112  DBdivindexBP.set(DBdivindexBP.get() + 1)
14113 
14114  if RUNstatus.get() == 0: # Update if stopped
14115  UpdateBodeTrace()
14116 #
14117 def BShowCurvesAllBP():
14118  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P
14119  ShowCA_VdB.set(1)
14120  ShowCA_P.set(1)
14121  ShowCB_VdB.set(1)
14122  ShowCB_P.set(1)
14123 
14124 def BShowCurvesNoneBP():
14125  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P
14126  ShowCA_VdB.set(0)
14127  ShowCA_P.set(0)
14128  ShowCB_VdB.set(0)
14129  ShowCB_P.set(0)
14130 # Bode Plot refresh
14131 def UpdateBodeAll(): # Update Data, trace and screen
14132  global FFTBuffA, FFTBuffB
14133  global SMPfft
14134 
14135  # DoFFT() # Fast Fourier transformation
14136  MakeBodeTrace() # Update the traces
14137  UpdateBodeScreen() # Update the screen
14138 
14139 def UpdateBodeTrace(): # Update trace and screen
14140  MakeBodeTrace() # Update traces
14141  UpdateBodeScreen() # Update the screen
14142 
14143 def UpdateBodeScreen(): # Update screen with trace and text
14144  MakeBodeScreen() # Update the screen
14145 
14146 # ============================================ Freq Main routine ====================================================
14147 
14148 def UpdateFreqAll(): # Update Data, trace and screen
14149  global FFTBuffA, FFTBuffB
14150  global SMPfft
14151 
14152  if len(FFTBuffA) < SMPfft and len(FFTBuffB) < SMPfft:
14153  return
14154 
14155  # DoFFT() # Fast Fourier transformation
14156  MakeFreqTrace() # Update the traces
14157  UpdateFreqScreen() # Update the screen
14158 
14159 def UpdateFreqTrace(): # Update trace and screen
14160  MakeFreqTrace() # Update traces
14161  UpdateFreqScreen() # Update the screen
14162 
14163 def UpdateFreqScreen(): # Update screen with trace and text
14164  MakeFreqScreen() # Update the screen
14165 
14166 def DoFFT(): # Fast Fourier transformation
14167  global FFTBuffA, FFTBuffB, AWGAwaveform, AWGBwaveform
14168  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowAWGASA, ShowAWGBSA
14169  global FFTmemoryA, FFTresultA, FFTresultAB, PhaseAB
14170  global FFTmemoryB, FFTresultB, FFTresultAWGA, FFTresultAWGB
14171  global FSweepAdB, FSweepBdB, FSweepAPh, FSweepBPh
14172  global PhaseA, PhaseB, PhaseMemoryA, PhaseMemoryB
14173  global FFTwindowshape, FFTbandwidth
14174  global AWGSAMPLErate, StartFreqEntry, StopFreqEntry, StartBodeEntry
14175  global SMPfft, LoopNum, IA_Ext_Conf
14176  global STARTsample, STOPsample, CutDC
14177  global TRACEaverage, FreqTraceMode, FSweepMode
14178  global TRACEresetFreq, ZEROstuffing
14179  global SpectrumScreenStatus, IAScreenStatus, BodeScreenStatus
14180  global NetworkScreenStatus, NSweepSeriesR, NSweepSeriesX, NSweepSeriesMag, NSweepSeriesAng
14181  global NSweepParallelR, NSweepParallelC, NSweepParallelL, NSweepSeriesC, NSweepSeriesL
14182 
14183  # T1 = time.time() # For time measurement of FFT routine
14184  REX = []
14185  PhaseA = []
14186  PhaseB = []
14187  # Convert list to numpy array REX for faster Numpy calculations
14188  # Take the first fft samples
14189  REX = numpy.array(FFTBuffA[0:SMPfft]) # Make a numpy arry of the list
14190 
14191  # Set Analog level display value MAX value is 5 volts for ALM1000
14192  REX = REX / 5.0
14193 
14194  # Do the FFT window function
14195  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
14196 
14197  # Zero stuffing of array for better interpolation of peak level of signals
14198  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
14199  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
14200 
14201  # Save previous trace in memory for max or average trace
14202  FFTmemoryA = FFTresultA
14203  if FreqTraceMode.get() == 3:
14204  PhaseMemoryA = PhaseA
14205 
14206  # FFT with numpy
14207  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
14208  PhaseA = numpy.angle(ALL, deg=True) # calculate angle
14209  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
14210  ALL = ALL * ALL # Convert from Voltage to Power (P = (V*V) / R; R = 1)
14211 
14212  le = int(len(ALL) / 2) # Only half is used, other half is mirror
14213  # ALL = ALL[0:le] # So take only first half of the array
14214  FFTresultA = ALL[0:le]
14215  PhaseA = PhaseA[0:le]
14216  RMScorr = 1.0 / SMPfft # For VOLTAGE!
14217  Powcorr = 50*(RMScorr **2) # vpktage squared For POWER!
14218  FFTresultA = FFTresultA * Powcorr
14219 #
14220  REX = []
14221  # Convert list to numpy array REX for faster Numpy calculations
14222  # Take the first fft samples
14223  REX = numpy.array(FFTBuffB[0:SMPfft]) # Make a numpy arry of the list
14224 
14225  # Set level display value MAX value is 5 volts for ALM1000
14226  REX = REX / 5.0
14227 
14228  # Do the FFT window function
14229  try:
14230  REX = REX * FFTwindowshape # The windowing shape function only over the samples
14231  except:
14232  return
14233  # Zero stuffing of array for better interpolation of peak level of signals
14234  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
14235  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
14236 
14237  # Save previous trace in memory for max or average trace
14238  FFTmemoryB = FFTresultB
14239  if FreqTraceMode.get() == 3:
14240  PhaseMemoryB = PhaseB
14241  # FFT with numpy
14242  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
14243  PhaseB = numpy.angle(ALL, deg=True) # calculate angle
14244  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
14245  ALL = ALL * ALL # Convert from Voltage to Power (P = (U*U) / R; R = 1)
14246 
14247  le = int(len(ALL) / 2 ) # Only half is used, other half is mirror
14248  # ALL = ALL[0:le] # So take only first half of the array
14249  FFTresultB = ALL[0:le]
14250  PhaseB = PhaseB[0:le]
14251  FFTresultB = FFTresultB * Powcorr
14252 #
14253  if IA_Ext_Conf.get() == 1: # calculate fft for voltage A-B for use if IA set to config 2
14254  REX = []
14255  PhaseAB = []
14256  # Convert list to numpy array REX for faster Numpy calculations
14257  # Take the first fft samples
14258  REX = numpy.array(FFTBuffA[0:SMPfft]-FFTBuffB[0:SMPfft]) # Make a numpy arry of the VA-VB list
14259 
14260  # Set level display value MAX value is 5 volts for ALM1000
14261  REX = REX / 5.0
14262 
14263  # Do the FFT window function
14264  REX = REX * FFTwindowshape # The windowing shape function only over the samples
14265 
14266  # Zero stuffing of array for better interpolation of peak level of signals
14267  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
14268  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
14269 
14270  # Save previous trace in memory for max or average trace
14271  # FFTmemoryB = FFTresultB
14272  # if FreqTraceMode.get() == 3:
14273  # PhaseMemoryB = PhaseB
14274  # FFT with numpy
14275  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
14276  PhaseAB = numpy.angle(ALL, deg=True) # calculate angle
14277  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
14278  ALL = ALL * ALL # Convert from Voltage to Power (P = (U*U) / R; R = 1)
14279 
14280  le = len(ALL) / 2 # Only half is used, other half is mirror
14281  #ALL = ALL[:le] # So take only first half of the array
14282  FFTresultAB = ALL[:le]
14283  PhaseAB = PhaseAB[:le]
14284  FFTresultAB = FFTresultAB * Powcorr
14285 #
14286  if ShowAWGASA.get() > 0:
14287  FFTAWGA = AWGAwaveform
14288  DCA = 0.0
14289  if CutDC.get() == 1:
14290  DCA = numpy.average(FFTAWGA)
14291  FFTAWGA = FFTAWGA - DCA
14292  if len(AWGAwaveform) < SMPfft:
14293  Repeats = math.ceil(SMPfft/len(AWGAwaveform))
14294  i = 0
14295  while i < Repeats:
14296  FFTAWGA = numpy.concatenate((FFTAWGA, AWGAwaveform-DCA))
14297  i = i + 1
14298  REX = []
14299  # Convert list to numpy array REX for faster Numpy calculations
14300  # Take the first fft samples
14301  REX = numpy.array(FFTAWGA[0:SMPfft]) # Make a numpy arry of the list
14302 
14303  # Set level display value MAX value is 5 volts for ALM1000
14304  REX = REX / 5.0
14305 
14306  # Do the FFT window function
14307  try:
14308  REX = REX * FFTwindowshape # The windowing shape function only over the samples
14309  except:
14310  return
14311  # Zero stuffing of array for better interpolation of peak level of signals
14312  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
14313  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
14314  # FFT with numpy
14315  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
14316  #PhaseB = numpy.angle(ALL, deg=True) # calculate angle
14317  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
14318  ALL = ALL * ALL # Convert from Voltage to Power (P = (U*U) / R; R = 1)
14319 
14320  le = int(len(ALL) / 2 ) # Only half is used, other half is mirror
14321  # ALL = ALL[0:le] # So take only first half of the array
14322  FFTresultAWGA = ALL[0:le]
14323  #PhaseB = PhaseB[0:le]
14324  FFTresultAWGA = FFTresultAWGA * Powcorr
14325 #
14326  if ShowAWGBSA.get() > 0:
14327  FFTAWGB = AWGBwaveform
14328  DCB = 0.0
14329  if CutDC.get() == 1:
14330  DCB = numpy.average(FFTAWGB)
14331  FFTAWGB = FFTAWGB - DCB
14332  if len(AWGBwaveform) < SMPfft:
14333  Repeats = math.ceil(SMPfft/len(AWGBwaveform))
14334  i = 1
14335  while i < Repeats:
14336  FFTAWGB = numpy.concatenate((FFTAWGB, AWGBwaveform-DCB))
14337  i = i + 1
14338  REX = []
14339  # Convert list to numpy array REX for faster Numpy calculations
14340  # Take the first fft samples
14341  REX = numpy.array(FFTAWGB[0:SMPfft]) # Make a numpy arry of the list
14342 
14343  # Set level display value MAX value is 5 volts for ALM1000
14344  REX = REX / 5.0
14345 
14346  # Do the FFT window function
14347  try:
14348  REX = REX * FFTwindowshape # The windowing shape function only over the samples
14349  except:
14350  return
14351  # Zero stuffing of array for better interpolation of peak level of signals
14352  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
14353  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
14354  # FFT with numpy
14355  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
14356  #PhaseB = numpy.angle(ALL, deg=True) # calculate angle
14357  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
14358  ALL = ALL * ALL # Convert from Voltage to Power (P = (U*U) / R; R = 1)
14359 
14360  le = int(len(ALL) / 2 ) # Only half is used, other half is mirror
14361  #ALL = ALL[0:le] # So take only first half of the array
14362  FFTresultAWGB = ALL[0:le]
14363  #PhaseB = PhaseB[0:le]
14364  FFTresultAWGB = FFTresultAWGB * Powcorr
14365 #
14366  TRACEsize = int(len(FFTresultB))
14367  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1)
14368  if SpectrumScreenStatus.get() > 0:
14369  try:
14370  StartFrequency = float(StartFreqEntry.get())
14371  except:
14372  StartFreqEntry.delete(0,"end")
14373  StartFreqEntry.insert(0,100)
14374  StartFrequency = 100
14375  STARTsample = int(StartFrequency / Fsample)
14376  else:
14377  STARTsample = 0
14378  if LoopNum.get() == 1:
14379  PhaseMemoryB = PhaseB
14380  FSweepAdB = []
14381  FSweepBdB = []
14382  FSweepAPh = []
14383  FSweepBPh = []
14384  if NetworkScreenStatus.get() > 0:
14385  NSweepSeriesR = []
14386  NSweepSeriesX = []
14387  NSweepSeriesMag = [] # in ohms
14388  NSweepSeriesAng = [] # in degrees
14389  NSweepParallelR = []
14390  NSweepParallelC = []
14391  NSweepParallelL = []
14392  NSweepSeriesC = []
14393  NSweepSeriesL = []
14394  if FreqTraceMode.get() == 1: # Normal mode 1, do not change
14395  if FSweepMode.get() == 1:
14396  ptmax = numpy.argmax(FFTresultA[STARTsample:TRACEsize])
14397  if ptmax > STARTsample:
14398  STARTsample = ptmax
14399  i = 0
14400  while i < 6:
14401  PhaseMemoryB[ptmax+i] = PhaseB[ptmax]
14402  i = i + 1
14403  if FSweepMode.get() == 2:
14404  ptmax = numpy.argmax(FFTresultB[STARTsample:TRACEsize])
14405  if ptmax > STARTsample:
14406  STARTsample = ptmax
14407  i = 0
14408  while i < 6:
14409  PhaseMemoryB[ptmax+i] = PhaseB[ptmax]
14410  i = i + 1
14411 
14412  if FreqTraceMode.get() == 2 and TRACEresetFreq == False: # Peak hold mode 2, change v to peak value
14413  if FSweepMode.get() == 1:
14414  ptmax = numpy.argmax(FFTresultA[STARTsample:TRACEsize])
14415  if ptmax > STARTsample:
14416  STARTsample = ptmax
14417  i = 0
14418  while i < 6:
14419  PhaseMemoryB[ptmax+i] = PhaseB[ptmax]
14420  i = i + 1
14421  if FSweepMode.get() == 2:
14422  ptmax = numpy.argmax(FFTresultB[STARTsample:TRACEsize])
14423  if ptmax > STARTsample:
14424  STARTsample = ptmax
14425  i = 0
14426  while i < 6:
14427  PhaseMemoryB[ptmax+i] = PhaseB[ptmax]
14428  i = i + 1
14429  if len(FFTresultB) == len(FFTmemoryB):
14430  FFTresultB = numpy.maximum(FFTresultB, FFTmemoryB)#
14431  if FreqTraceMode.get() == 3 and TRACEresetFreq == False: # Average mode 3, add difference / TRACEaverage to v
14432  try:
14433  FFTresultB = FFTmemoryB + (FFTresultB - FFTmemoryB) / TRACEaverage.get()
14434  PhaseB = PhaseMemoryB +(PhaseB - PhaseMemoryB) / TRACEaverage.get()
14435  except:
14436  FFTmemoryB = FFTresultB
14437  PhaseMemoryB = PhaseB
14438 #
14439  TRACEsize = int(len(FFTresultA))
14440  Fsample = float(AWGSAMPLErate / 2) / (TRACEsize - 1)
14441  if SpectrumScreenStatus.get() > 0:
14442  STARTsample = int(StartFrequency / Fsample)
14443  else:
14444  STARTsample = 0
14445  if LoopNum.get() == 1:
14446  PhaseMemoryA = PhaseA
14447  if FreqTraceMode.get() == 1: # Normal mode 1, do not change
14448  if FSweepMode.get() == 1:
14449  ptmax = numpy.argmax(FFTresultA[STARTsample:TRACEsize])
14450  if ptmax > STARTsample:
14451  STARTsample = ptmax
14452  i = 0
14453  while i < 6:
14454  PhaseMemoryA[ptmax+i] = PhaseA[ptmax]
14455  i = i + 1
14456  if FSweepMode.get() == 2:
14457  ptmax = numpy.argmax(FFTresultB[STARTsample:TRACEsize])
14458  if ptmax > STARTsample:
14459  STARTsample = ptmax
14460  i = 0
14461  while i < 6:
14462  PhaseMemoryA[ptmax+i] = PhaseA[ptmax]
14463  i = i + 1
14464 
14465  if FreqTraceMode.get() == 2 and TRACEresetFreq == False: # Peak hold mode 2, change v to peak value
14466  if FSweepMode.get() == 1:
14467  ptmax = numpy.argmax(FFTresultA[STARTsample:TRACEsize])
14468  if ptmax > STARTsample:
14469  STARTsample = ptmax
14470  i = 0
14471  while i < 6:
14472  PhaseMemoryA[ptmax+i] = PhaseA[ptmax]
14473  i = i + 1
14474  if FSweepMode.get() == 2:
14475  ptmax = numpy.argmax(FFTresultB[STARTsample:TRACEsize])
14476  if ptmax > STARTsample:
14477  STARTsample = ptmax
14478  i = 0
14479  while i < 6:
14480  PhaseMemoryA[ptmax+i] = PhaseA[ptmax]
14481  i = i + 1
14482 #
14483  if len(FFTresultA) == len(FFTmemoryA):
14484  FFTresultA = numpy.maximum(FFTresultA, FFTmemoryA)
14485  if FreqTraceMode.get() == 3 and TRACEresetFreq == False: # Average mode 3, add difference / TRACEaverage to v
14486  try:
14487  FFTresultA = FFTmemoryA + (FFTresultA - FFTmemoryA) / TRACEaverage.get()
14488  PhaseA = PhaseMemoryA +(PhaseA - PhaseMemoryA) / TRACEaverage.get()
14489  except:
14490  FFTmemoryA = FFTresultA
14491  PhaseMemoryA = PhaseA
14492 #
14493  if FSweepMode.get() > 0 and BodeScreenStatus.get() > 0:
14494  FSweepAdB.append(numpy.amax(FFTresultA))
14495  FSweepBdB.append(numpy.amax(FFTresultB))
14496  FSweepAPh.append(PhaseA[numpy.argmax(FFTresultA)])
14497  FSweepBPh.append(PhaseB[numpy.argmax(FFTresultB)])
14498 
14499  TRACEresetFreq = False # Trace reset done
14500 
14501 def MakeFreqTrace(): # Update the grid and trace
14502  global FFTmemoryA, FFTresultA
14503  global FFTmemoryB, FFTresultB
14504  global FFTresultAWGA, FFTresultAWGB, ShowAWGASA, ShowAWGBSA
14505  global PhaseA, PhaseB, PhaseMemoryA, PhaseMemoryB
14506  global FSweepAdB, FSweepBdB, FSweepAPh, FSweepBPh, FStep
14507  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowMathSA
14508  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
14509  global PeakxM, PeakyM, PeakMdb, PeakfreqM, PeakIndexA, PeakIndexB
14510  global PeakfreqA, PeakfreqB, Two_X_Sample
14511  global DBdivindex # Index value
14512  global DBdivlist # dB per division list
14513  global DBlevel # Reference level
14514  global GRHF,GRWF # Screenheight, Screenwidth
14515  global AWGSAMPLErate, HScale, Fsample, SAMPLErate, BaseSampleRate
14516  global StartFreqEntry, StopFreqEntry, PhCenFreqEntry, RelPhaseCenter
14517  global STARTsample, STOPsample, LoopNum, FSweepMode, FreqTraceMode, SMPfft
14518  global SAVScale, SAVPSD, SAvertmaxEntry, SAvertminEntry, SAvertmax, SAvertmin
14519  global T1Fline, T2Fline, TFMline, T1Pline, T2Pline, TAFline, TBFline
14520  global Vdiv # Number of vertical divisions
14521  global X0LF, Y0TF # Left top X value, Left top Y value
14522 
14523  # Set the TRACEsize variable
14524  TRACEsize = 0
14525  try:
14526  StartFrequency = float(StartFreqEntry.get())
14527  except:
14528  StartFreqEntry.delete(0,"end")
14529  StartFreqEntry.insert(0,100)
14530  StartFrequency = 100
14531  try:
14532  StopFrequency = float(StopFreqEntry.get())
14533  except:
14534  StopFreqEntry.delete(0,"end")
14535  StopFreqEntry.insert(0,50000)
14536  StopFrequency = 50000
14537  if StartFrequency > StopFrequency :
14538  StopFreqEntry.delete(0,"end")
14539  StopFreqEntry.insert(0,50000)
14540  StopFrequency = 50000
14541  if StopFrequency < StartFrequency :
14542  StopFreqEntry.delete(0,"end")
14543  StopFreqEntry.insert(0,50000)
14544  StopFrequency = 50000
14545  try:
14546  Phasecenter = int(PhCenFreqEntry.get())
14547  RelPhaseCenter.set(Phasecenter)
14548  except:
14549  PhCenFreqEntry.delete(0,"end")
14550  PhCenFreqEntry.insert(0,0)
14551  RelPhaseCenter.set(0)
14552  Phasecenter = 0
14553  try: # from list ("10.0", "1.0" , "0.1", "10mV", "1mV", "100uV", "10uV", "1uV", "100nV" , "10nV")
14554  if SAvertmaxEntry.get() == "10.0":
14555  SAvertmax = 10.0
14556  elif SAvertmaxEntry.get() == "1.0":
14557  SAvertmax = 1.0
14558  elif SAvertmaxEntry.get() == "0.1":
14559  SAvertmax = 0.1
14560  elif SAvertmaxEntry.get() == "10mV":
14561  SAvertmax = 1.0E-2
14562  elif SAvertmaxEntry.get() == "1mV":
14563  SAvertmax = 1.0E-3
14564  elif SAvertmaxEntry.get() == "100uV":
14565  SAvertmax = 1.0E-4
14566  elif SAvertmaxEntry.get() == "10uV":
14567  SAvertmax = 1.0E-5
14568  elif SAvertmaxEntry.get() == "1uV":
14569  SAvertmax = 1.0E-6
14570  elif SAvertmaxEntry.get() == "100nV":
14571  SAvertmax = 1.0E-7
14572  elif SAvertmaxEntry.get() == "10nV":
14573  SAvertmax = 1.0E-8
14574  else:
14575  SAvertmax = float(SAvertmaxEntry.get())
14576  if SAvertmax < 0.0: # negative values not allowed
14577  SAvertmaxEntry.delete(0,"end")
14578  SAvertmaxEntry.insert(0, "1mV")
14579  SAvertmax = 1.0E-3
14580  except:
14581  SAvertmaxEntry.delete(0,"end")
14582  SAvertmaxEntry.insert(0, "1mV")
14583  SAvertmax = 1.0E-3
14584  try: # from list ("10.0", "1.0" , "0.1", "10mV", "1mV", "100uV", "10uV", "1uV", "100nV" , "10nV")
14585  if SAvertminEntry.get() == "10.0":
14586  SAvertmin = 10.0
14587  elif SAvertminEntry.get() == "1.0":
14588  SAvertmin = 1.0
14589  elif SAvertminEntry.get() == "0.1":
14590  SAvertmin = 0.1
14591  elif SAvertminEntry.get() == "10mV":
14592  SAvertmin = 1.0E-2
14593  elif SAvertminEntry.get() == "1mV":
14594  SAvertmin = 1.0E-3
14595  elif SAvertminEntry.get() == "100uV":
14596  SAvertmin = 1.0E-4
14597  elif SAvertminEntry.get() == "10uV":
14598  SAvertmin = 1.0E-5
14599  elif SAvertminEntry.get() == "1uV":
14600  SAvertmin = 1.0E-6
14601  elif SAvertminEntry.get() == "100nV":
14602  SAvertmin = 1.0E-7
14603  elif SAvertminEntry.get() == "10nV":
14604  SAvertmin = 1.0E-8
14605  else:
14606  SAvertmin = float(SAvertminEntry.get())
14607  if SAvertmin < 0.0: # negative values not allowed
14608  SAvertminEntry.delete(0,"end")
14609  SAvertminEntry.insert(0, "1uV")
14610  SAvertmin = 1.0E-6
14611  except:
14612  SAvertminEntry.delete(0,"end")
14613  SAvertminEntry.insert(0, "1uV")
14614  SAvertmin = 1.0E-6
14615  if ShowC1_VdB.get() == 1 or ShowMathSA.get() > 0:
14616  TRACEsize = len(FFTresultA) # Set the trace length
14617  elif ShowC2_VdB.get() == 1 or ShowMathSA.get() > 0:
14618  TRACEsize = len(FFTresultB)
14619  elif ShowAWGASA.get() > 0:
14620  TRACEsize = len(FFTresultAWGA)
14621  elif ShowAWGBSA.get() > 0:
14622  TRACEsize = len(FFTresultAWGB)
14623  #print(TRACEsize)
14624  if TRACEsize == 0: # If no trace, skip rest of this routine
14625  return()
14626  if FSweepMode.get() > 0 and LoopNum.get() == NSteps.get():
14627  PhaseA = PhaseMemoryA
14628  PhaseB = PhaseMemoryB
14629  FBinWidth = float(SAMPLErate / 2.0) / (TRACEsize - 1) # Frequency step per sample
14630  # Vertical conversion factors (level dBs) and border limits
14631  Yconv = float(GRHF) / (Vdiv.get() * DBdivlist[DBdivindex.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
14632  YVconv = float(GRHF) / (SAvertmax - SAvertmin) # * Vdiv.get()
14633  Yc = float(Y0TF) + Yconv * (DBlevel.get()) # Yc is the 0 dBm position, can be outside the screen!
14634  YVc = float(Y0TF) + YVconv * SAvertmax
14635  Ymin = Y0TF # Minimum position of screen grid (top)
14636  Ymax = Y0TF + GRHF # Maximum position of screen grid (bottom)
14637  Yphconv = float(GRHF) / 360
14638  Yp = float(Y0TF) + Yphconv + 180
14639  # Horizontal conversion factors (frequency Hz) and border limits
14640  Fpixel = (StopFrequency - StartFrequency) / GRWF # Frequency step per screen pixel
14641  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1) # Frequency step per sample
14642  LogFStop = math.log10(StopFrequency)
14643  try:
14644  LogFStart = math.log10(StartFrequency)
14645  except:
14646  LogFStart = 0.0
14647  LogFpixel = (LogFStop - LogFStart) / GRWF
14648  #
14649  try:
14650  LogVStop = math.log10(SAvertmax)
14651  except:
14652  LogVStop = 0.0
14653  try:
14654  LogVStart = math.log10(SAvertmin)
14655  except:
14656  LogVStart = -10
14657  LogVpixel = (LogVStop - LogVStart) / GRHF
14658  #
14659  STARTsample = StartFrequency / Fsample # First sample in FFTresult[] that is used
14660  STARTsample = int(math.ceil(STARTsample)) # First within screen range
14661 
14662  STOPsample = StopFrequency / Fsample # Last sample in FFTresult[] that is used
14663  STOPsample = int(math.floor(STOPsample)) # Last within screen range, math.floor actually not necessary, part of int
14664 
14665  MAXsample = TRACEsize # Just an out of range check
14666  if STARTsample > (MAXsample - 1):
14667  STARTsample = MAXsample - 1
14668 
14669  if STOPsample > MAXsample:
14670  STOPsample = MAXsample
14671 
14672  T1Fline = []
14673  T2Fline = []
14674  TAFline = []
14675  TBFline = []
14676  T1Pline = []
14677  T2Pline = []
14678  TFMline = []
14679  n = STARTsample
14680  PeakIndexA = PeakIndexB = n
14681  PeakdbA = PeakdbB = PeakMdb = -200 # PeakdbB
14682  while n <= STOPsample:
14683  F = n * Fsample
14684  if HScale.get() == 1:
14685  try:
14686  LogF = math.log10(F) # convet to log Freq
14687  x = X0LF + (LogF - LogFStart)/LogFpixel
14688  except:
14689  x = X0LF
14690  else:
14691  x = X0LF + (F - StartFrequency) / Fpixel
14692  if ShowC1_VdB.get() == 1:
14693  T1Fline.append(int(x + 0.5))
14694  try:
14695  if SAVScale.get() == 0:
14696  if SAVPSD.get() == 1:
14697  dbA = 10 * math.log10(float(FFTresultA[n])/math.sqrt(FBinWidth))
14698  else:
14699  dbA = 10 * math.log10(float(FFTresultA[n])) # Convert power to DBs
14700  ya = Yc - Yconv * dbA
14701  else:
14702  dbA = 10 * math.log10(float(FFTresultA[n])) # Convert power to DBs
14703  V = 10.0**(dbA/20.0)# convert back to RMS Volts
14704  if SAVPSD.get() == 1:
14705  V = V/math.sqrt(FBinWidth) # per root Hz
14706  if SAVScale.get() == 2:
14707  try:
14708  LogV = math.log10(V) # convet to log Volts
14709  ya = YVc - (LogV - LogVStart)/LogVpixel
14710  except:
14711  ya = YVc - YVconv * V
14712  else:
14713  ya = YVc - YVconv * V
14714  except:
14715  ya = Ymax
14716  if (ya < Ymin):
14717  ya = Ymin
14718  if (ya > Ymax):
14719  ya = Ymax
14720  if dbA > PeakdbA:
14721  PeakdbA = dbA
14722  PeakyA = int(ya + 0.5)
14723  PeakxA = int(x + 0.5)
14724  PeakfreqA = F
14725  PeakIndexA = n
14726  T1Fline.append(int(ya + 0.5))
14727  if ShowC2_VdB.get() == 1:
14728  T2Fline.append(int(x + 0.5))
14729  try:
14730  if SAVScale.get() == 0:
14731  if SAVPSD.get() == 1:
14732  dbB = 10 * math.log10(float(FFTresultB[n])/math.sqrt(FBinWidth))
14733  else:
14734  dbB = 10 * math.log10(float(FFTresultB[n])) # Convert power to DBs
14735  yb = Yc - Yconv * dbB
14736  else:
14737  dbB = 10 * math.log10(float(FFTresultB[n])) # Convert power to DBs
14738  V = 10.0**(dbB/20.0)# RMS Volts
14739  if SAVPSD.get() == 1:
14740  V = V/math.sqrt(FBinWidth) # per root Hz
14741  if SAVScale.get() == 2:
14742  try:
14743  LogV = math.log10(V) # convet to log Volts
14744  yb = YVc - (LogV - LogVStart)/LogVpixel
14745  except:
14746  yb = YVc - YVconv * V
14747  else:
14748  yb = YVc - YVconv * V
14749  except:
14750  yb = Ymax
14751  if (yb < Ymin):
14752  yb = Ymin
14753  if (yb > Ymax):
14754  yb = Ymax
14755  if dbB > PeakdbB:
14756  PeakdbB = dbB
14757  PeakyB = int(yb + 0.5)
14758  PeakxB = int(x + 0.5)
14759  PeakfreqB = F
14760  PeakIndexB = n
14761  T2Fline.append(int(yb + 0.5))
14762  if ShowAWGASA.get() > 0:
14763  TAFline.append(int(x + 0.5))
14764  try:
14765  if SAVPSD.get() == 1:
14766  dbA = 10 * math.log10(float(FFTresultAWGA[n])/math.sqrt(FBinWidth)) # Convert power to DBs
14767  else:
14768  dbA = 10 * math.log10(float(FFTresultAWGA[n])) # Convert power to DBs
14769  ya = Yc - Yconv * dbA
14770  except:
14771  ya = Ymax
14772  if (ya < Ymin):
14773  ya = Ymin
14774  if (ya > Ymax):
14775  ya = Ymax
14776  TAFline.append(int(ya + 0.5))
14777  if ShowAWGBSA.get() > 0:
14778  TBFline.append(int(x + 0.5))
14779  try:
14780  if SAVPSD.get() == 1:
14781  dbA = 10 * math.log10(float(FFTresultAWGB[n])/math.sqrt(FBinWidth)) # Convert power to DBs
14782  else:
14783  dbA = 10 * math.log10(float(FFTresultAWGb[n])) # Convert power to DBs
14784  ya = Yc - Yconv * dbA
14785  except:
14786  ya = Ymax
14787  if (ya < Ymin):
14788  ya = Ymin
14789  if (ya > Ymax):
14790  ya = Ymax
14791  TBFline.append(int(ya + 0.5))
14792  if ShowC1_P.get() == 1:
14793  T1Pline.append(int(x + 0.5))
14794  if FSweepMode.get() > 0:
14795  RelPhase = PhaseMemoryA[n]-PhaseMemoryB[n]
14796  else:
14797  RelPhase = PhaseA[n]-PhaseB[n]
14798  RelPhase = RelPhase - Phasecenter
14799  if RelPhase > 180:
14800  RelPhase = RelPhase - 360
14801  elif RelPhase < -180:
14802  RelPhase = RelPhase + 360
14803  if Two_X_Sample.get() == 0:
14804  PhErr = 0.0018 * n * Fsample # calculate phase error due half sample period offset
14805  RelPhase = RelPhase + PhErr - 12.0
14806  else:
14807  RelPhase = RelPhase - 9.0
14808  ya = Yp - Yphconv * RelPhase
14809  T1Pline.append(int(ya + 0.5))
14810  if ShowC2_P.get() == 1:
14811  T2Pline.append(int(x + 0.5))
14812  if FSweepMode.get() > 0:
14813  RelPhase = PhaseMemoryB[n]-PhaseMemoryA[n]
14814  else:
14815  RelPhase = PhaseB[n]-PhaseA[n]
14816  RelPhase = RelPhase - Phasecenter
14817  if RelPhase > 180:
14818  RelPhase = RelPhase - 360
14819  elif RelPhase < -180:
14820  RelPhase = RelPhase + 360
14821  if Two_X_Sample.get() == 0:
14822  PhErr = 0.0018 * n * Fsample # calculate pahse error due half sample period offset
14823  RelPhase = RelPhase - PhErr - 12.0
14824  else:
14825  RelPhase = RelPhase - 9.0
14826  ya = Yp - Yphconv * RelPhase
14827  T2Pline.append(int(ya + 0.5))
14828  if ShowMathSA.get() > 0:
14829  TFMline.append(int(x + 0.5))
14830  if SAVPSD.get() == 1:
14831  dbA = 10 * math.log10(float(FFTresultA[n])/math.sqrt(FBinWidth)) # Convert power to DBs
14832  dbB = 10 * math.log10(float(FFTresultB[n])/math.sqrt(FBinWidth))
14833  else:
14834  dbA = 10 * math.log10(float(FFTresultA[n])) # Convert power to DBs
14835  dbB = 10 * math.log10(float(FFTresultB[n]))
14836  if ShowMathSA.get() == 1:
14837  MdB = dbA - dbB
14838  elif ShowMathSA.get() == 2:
14839  MdB = dbB - dbA
14840  yb = Yc - Yconv * MdB
14841  if (yb < Ymin):
14842  yb = Ymin
14843  if (yb > Ymax):
14844  yb = Ymax
14845  if MdB > PeakMdb:
14846  PeakMdb = MdB
14847  PeakyM = int(yb + 0.5)
14848  PeakxM = int(x + 0.5)
14849  PeakfreqM = F
14850  TFMline.append(int(yb + 0.5))
14851  n = n + 1
14852 #
14853 # make Bode Plot Traces
14854 def MakeBodeTrace(): # Update the grid and trace
14855  global FSweepAdB, FSweepBdB, FSweepAPh, FSweepBPh, FStep, FBins
14856  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, ShowMathBP
14857  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
14858  global PeakxM, PeakyM, PeakMdb, PeakfreqM
14859  global PeakfreqA, PeakfreqB, Two_X_Sample, PhaseOffset1x, PhaseOffset2x
14860  global DBdivindexBP # Index value
14861  global DBdivlist # dB per division list
14862  global DBlevelBP # Reference level
14863  global GRHBP # Screenheight
14864  global GRWBP # Screenwidth
14865  global AWGSAMPLErate, HScaleBP, RUNstatus, SAMPLErate, BaseSampleRate
14866  global StartBodeEntry, StopBodeEntry, SMPfft
14867  global STARTsample, STOPsample, LoopNum, FSweepMode
14868  global FreqTraceMode, RelPhaseCenter, PhCenBodeEntry, ImCenBodeEntry, ImpedanceCenter, Impedcenter
14869  global TAFline, TBFline, TBPMline, TAPline, TBPline
14870  global Vdiv # Number of vertical divisions
14871  global X0LBP # Left top X value
14872  global Y0TBP # Left top Y value
14873  global ResScale, NetworkScreenStatus, Show_Rseries, NSweepSeriesR, Show_Xseries, NSweepSeriesX
14874  global Show_Magnitude, NSweepSeriesMag, Show_Angle, NSweepSeriesAng
14875  global TIARline, TIAXline, TIAMagline, TIAAngline, CurrentFreqX
14876 
14877  # Set the TRACEsize variable
14878  TRACEsize = 0
14879  if ShowCA_VdB.get() == 1 or ShowMathBP.get() > 0:
14880  TRACEsize = len(FStep) # Set the trace length
14881  elif ShowCB_VdB.get() == 1 or ShowMathBP.get() > 0:
14882  TRACEsize = len(FStep)
14883  if TRACEsize == 0: # If no trace, skip rest of this routine
14884  return()
14885  #
14886  try:
14887  EndFreq = float(StopBodeEntry.get())
14888  except:
14889  StopBodeEntry.delete(0,"end")
14890  StopBodeEntry.insert(0,10000)
14891  EndFreq = 10000
14892  try:
14893  BeginFreq = float(StartBodeEntry.get())
14894  except:
14895  StartBodeEntry.delete(0,"end")
14896  StartBodeEntry.insert(0,100)
14897  BeginFreq = 100
14898  try:
14899  Phasecenter = float(PhCenBodeEntry.get())
14900  RelPhaseCenter.set(Phasecenter)
14901  except:
14902  PhCenBodeEntry.delete(0,"end")
14903  PhCenBodeEntry.insert(0,0)
14904  RelPhaseCenter.set(0)
14905  Phasecenter = 0
14906  try:
14907  Impedcenter = float(ImCenBodeEntry.get())
14908  ImpedanceCenter.set(Impedcenter)
14909  except:
14910  ImCenBodeEntry.delete(0,"end")
14911  ImCenBodeEntry.insert(0,0)
14912  ImpedanceCenter.set(0)
14913  Impedcenter = 0
14914  #
14915  HalfSAMPLErate = SAMPLErate/2
14916  BeginIndex = int((BeginFreq/HalfSAMPLErate)*16384)
14917  EndIndex = int((EndFreq/HalfSAMPLErate)*16384)
14918  CurrentFreqX = X0LBP + 14
14919  if FSweepMode.get() > 0 and len(FSweepAdB) > 4:
14920  # Vertical conversion factors (level dBs) and border limits
14921  Yconv = float(GRHBP) / (Vdiv.get() * DBdivlist[DBdivindexBP.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
14922  Yc = float(Y0TBP) + Yconv * (DBlevelBP.get()) # Yc is the 0 dBm position, can be outside the screen!
14923  Ymin = Y0TBP # Minimum position of screen grid (top)
14924  Ymax = Y0TBP + GRHBP # Maximum position of screen grid (bottom)
14925  Yphconv = float(GRHBP) / 360 # degrees per pixel
14926  Yp = float(Y0TBP) + Yphconv + 180
14927  x1 = X0LBP + 14
14928  # Horizontal conversion factors (frequency Hz) and border limits
14929  Fpixel = (EndFreq - BeginFreq) / GRWBP # Frequency step per screen pixel
14930  LogFStop = math.log10(EndFreq)
14931  try:
14932  LogFStart = math.log10(BeginFreq)
14933  except:
14934  LogFStart = 0.0
14935  LogFpixel = (LogFStop - LogFStart) / GRWBP
14936  TAFline = []
14937  TBFline = []
14938  TAPline = []
14939  TBPline = []
14940  TIARline = []
14941  TIAXline = []
14942  TIAMagline = []
14943  TIAAngline = []
14944  TBPMline = []
14945  PeakdbA = -200
14946  PeakdbB = -200
14947  PeakMdb = -200
14948  n = 0
14949  for n in range(len(FSweepAdB)): # while n < len(FStep):
14950  if n < len(FStep): # check if n has gone out off bounds because user did something dumb
14951  F = FBins[int(FStep[n])] # look up frequency bin in list of bins
14952  else:
14953  F = FBins[int(FStep[0])]
14954  if F >= BeginFreq and F <= EndFreq:
14955  if HScaleBP.get() == 1:
14956  try:
14957  LogF = math.log10(F) # convet to log Freq
14958  x = x1 + (LogF - LogFStart)/LogFpixel
14959  except:
14960  x = x1
14961  else:
14962  x = x1 + (F - BeginFreq) / Fpixel
14963  CurrentFreqX = x
14964  if ShowCA_VdB.get() == 1:
14965  TAFline.append(int(x + 0.5))
14966  try:
14967  dbA = 10 * math.log10(float(FSweepAdB[n])) # Convert power to DBs, except for log(0) error
14968  ya = Yc - Yconv * dbA
14969  except:
14970  ya = Ymax
14971  if (ya < Ymin):
14972  ya = Ymin
14973  if (ya > Ymax):
14974  ya = Ymax
14975  if dbA > PeakdbA:
14976  PeakdbA = dbA
14977  PeakyA = int(ya + 0.5)
14978  PeakxA = int(x + 0.5)
14979  PeakfreqA = F
14980  TAFline.append(int(ya + 0.5))
14981  if ShowCB_VdB.get() == 1:
14982  TBFline.append(int(x + 0.5))
14983  try:
14984  dbB = 10 * math.log10(float(FSweepBdB[n]))
14985  yb = Yc - Yconv * dbB
14986  except:
14987  yb = Ymax
14988  if (yb < Ymin):
14989  yb = Ymin
14990  if (yb > Ymax):
14991  yb = Ymax
14992  if dbB > PeakdbB:
14993  PeakdbB = dbB
14994  PeakyB = int(yb + 0.5)
14995  PeakxB = int(x + 0.5)
14996  PeakfreqB = F
14997  TBFline.append(int(yb + 0.5))
14998  if ShowCA_P.get() == 1:
14999  TAPline.append(int(x + 0.5))
15000  RelPhase = FSweepAPh[n] - FSweepBPh[n]
15001  RelPhase = RelPhase - Phasecenter
15002  if RelPhase > 180:
15003  RelPhase = RelPhase - 360
15004  elif RelPhase < -180:
15005  RelPhase = RelPhase + 360
15006  if Two_X_Sample.get() == 0:
15007  PhErr = 0.0018 * F # calculate phase error due half sample period offset
15008  RelPhase = RelPhase + PhErr - PhaseOffset1x
15009  else:
15010  RelPhase = RelPhase - PhaseOffset2x
15011  ya = Yp - Yphconv * RelPhase
15012  TAPline.append(int(ya + 0.5))
15013  if ShowCB_P.get() == 1:
15014  TBPline.append(int(x + 0.5))
15015  RelPhase = FSweepBPh[n] - FSweepAPh[n]
15016  RelPhase = RelPhase - Phasecenter
15017  if RelPhase > 180:
15018  RelPhase = RelPhase - 360
15019  elif RelPhase < -180:
15020  RelPhase = RelPhase + 360
15021  if Two_X_Sample.get() == 0:
15022  PhErr = 0.0018 * F # calculate phase error due half sample period offset
15023  RelPhase = RelPhase - PhErr - PhaseOffset1x
15024  else:
15025  RelPhase = RelPhase - PhaseOffset2x
15026  ya = Yp - Yphconv * RelPhase
15027  TBPline.append(int(ya + 0.5))
15028  if ShowMathBP.get() > 0:
15029  TBPMline.append(int(x + 0.5))
15030  dbA = 10 * math.log10(float(FSweepAdB[n])) # Convert power to DBs, except for log(0) error
15031  dbB = 10 * math.log10(float(FSweepBdB[n]))
15032  if ShowMathBP.get() == 1:
15033  MdB = dbA - dbB
15034  elif ShowMathBP.get() == 2:
15035  MdB = dbB - dbA
15036  yb = Yc - Yconv * MdB
15037  if (yb < Ymin):
15038  yb = Ymin
15039  if (yb > Ymax):
15040  yb = Ymax
15041  if MdB > PeakMdb:
15042  PeakMdb = MdB
15043  PeakyM = int(yb + 0.5)
15044  PeakxM = int(x + 0.5)
15045  PeakfreqM = F
15046  TBPMline.append(int(yb + 0.5))
15047 # draw impedance trace if necessary
15048  if NetworkScreenStatus.get() > 0:
15049  ycenter = Y0TBP + (GRHBP/2)
15050  OhmsperPixel = float(ResScale.get())*Vdiv.get()/GRHBP
15051  n = 0
15052  for n in range(len(NSweepSeriesR)): # while n < len(FStep):
15053  if n < len(FStep): # check if n has gone out off bounds because user did something dumb
15054  F = FBins[int(FStep[n])] # look up frequency bin in list of bins
15055  else:
15056  F = FBins[int(FStep[0])]
15057  if F >= BeginFreq and F <= EndFreq:
15058  if HScaleBP.get() == 1:
15059  try:
15060  LogF = math.log10(F) # convet to log Freq
15061  x = x1 + (LogF - LogFStart)/LogFpixel
15062  except:
15063  x = x1
15064  else:
15065  x = x1 + (F - BeginFreq) / Fpixel
15066  if Show_Rseries.get() == 1:
15067  TIARline.append(int(x + 0.5))
15068  y1 = ycenter - ((NSweepSeriesR[n]-Impedcenter) / OhmsperPixel)
15069  if (y1 < Ymin):
15070  y1 = Ymin
15071  if (y1 > Ymax):
15072  y1 = Ymax
15073  TIARline.append(y1)
15074  if Show_Xseries.get() == 1:
15075  TIAXline.append(int(x + 0.5))
15076  y1 = ycenter - ((NSweepSeriesX[n]-Impedcenter) / OhmsperPixel)
15077  if (y1 < Ymin):
15078  y1 = Ymin
15079  if (y1 > Ymax):
15080  y1 = Ymax
15081  TIAXline.append(y1)
15082  if Show_Magnitude.get() == 1:
15083  TIAMagline.append(int(x + 0.5))
15084  y1 = ycenter - ((NSweepSeriesMag[n]-Impedcenter) / OhmsperPixel)
15085  if (y1 < Ymin):
15086  y1 = Ymin
15087  if (y1 > Ymax):
15088  y1 = Ymax
15089  TIAMagline.append(y1)
15090  if Show_Angle.get() == 1:
15091  TIAAngline.append(int(x + 0.5))
15092  y1 = ycenter - Yphconv * (NSweepSeriesAng[n]-Phasecenter)
15093  if (y1 < Ymin):
15094  y1 = Ymin
15095  if (y1 > Ymax):
15096  y1 = Ymax
15097  TIAAngline.append(y1)
15098 #
15099 def MakeBodeScreen(): # Update the screen with traces and text
15100  global CANVASheightBP, CANVASwidthBP, SmoothCurvesBP
15101  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
15102  global PeakxM, PeakyM, PeakMdb, PeakfreqM
15103  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
15104  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
15105  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM
15106  global COLORgrid # The colors
15107  global COLORsignalband, COLORtext
15108  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5, COLORtrace6, COLORtrace7
15109  global FSweepMode, LoopNum, MarkerFreqNum, TRACEwidth, GridWidth
15110  global DBdivindexBP # Index value
15111  global DBdivlist # dB per division list
15112  global DBlevelBP # Reference level
15113  global FFTwindow, FFTbandwidth, ZEROstuffing, FFTwindowname
15114  global X0LBP # Left top X value
15115  global Y0TBP # Left top Y value
15116  global GRWBP # Screenwidth
15117  global GRHBP # Screenheight
15118  global FontSize
15119  global RUNstatus # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
15120  global AWGSAMPLErate, HScaleBP, SAMPLErate, BaseSampleRate
15121  global SMPfft # number of FFT samples
15122  global StartBodeEntry, StopBodeEntry
15123  global ShowCA_P, ShowCB_P, ShowRA_VdB, ShowRB_VdB, ShowMarkerBP
15124  global ShowCA_RdB, ShowCA_RP, ShowCB_RdB, ShowCB_RP
15125  global ShowMathBP, BodeDisp, RelPhaseCenter, PhCenBodeEntry, ImCenBodeEntry, ImpedanceCenter, Impedcenter
15126  global ShowBPCur, ShowBdBCur, BPCursor, BdBCursor
15127  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle, NetworkScreenStatus
15128  global Show_RseriesRef, Show_XseriesRef, Show_MagnitudeRef, Show_AngleRef
15129  global TAFline, TBFline, TAPline, TAFRline, TBFRline, TBPMline, TBPRMline
15130  global TAPRline, TBPRline
15131  global TRACEaverage # Number of traces for averageing
15132  global FreqTraceMode # 1 normal 2 max 3 average
15133  global Vdiv, ResScale # Number of vertical divisions
15134  global TIARline, TIAXline, TIAMagline, TIAAngline, CurrentFreqX
15135  global RefIARline, RefIAXline, RefIAMagline, RefIAAngline
15136 
15137  # Delete all items on the screen
15138  MarkerFreqNum = 0
15139  Bodeca.delete(ALL) # remove all items
15140 
15141  try:
15142  EndFreq = float(StopBodeEntry.get())
15143  except:
15144  StopBodeEntry.delete(0,"end")
15145  StopBodeEntry.insert(0,10000)
15146  EndFreq = 10000
15147  try:
15148  BeginFreq = float(StartBodeEntry.get())
15149  except:
15150  StartBodeEntry.delete(0,"end")
15151  StartBodeEntry.insert(0,100)
15152  BeginFreq = 100
15153  try:
15154  Phasecenter = float(PhCenBodeEntry.get())
15155  RelPhaseCenter.set(Phasecenter)
15156  except:
15157  PhCenBodeEntry.delete(0,"end")
15158  PhCenBodeEntry.insert(0,0)
15159  RelPhaseCenter.set(0)
15160  Phasecenter = 0
15161  try:
15162  Impedcenter = float(ImCenBodeEntry.get())
15163  ImpedanceCenter.set(Impedcenter)
15164  except:
15165  ImCenBodeEntry.delete(0,"end")
15166  ImCenBodeEntry.insert(0,0)
15167  ImpedanceCenter.set(0)
15168  Impedcenter = 0
15169  #
15170  # Draw horizontal grid lines
15171  i = 0
15172  x1 = X0LBP + 14
15173  x2 = x1 + GRWBP
15174  while (i <= Vdiv.get()):
15175  y = Y0TBP + i * GRHBP/Vdiv.get()
15176  Dline = [x1,y,x2,y]
15177  if i == 0 or i == Vdiv.get():
15178  Bodeca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
15179  else:
15180  Bodeca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
15181  Vaxis_value = (DBlevelBP.get() - (i * DBdivlist[DBdivindexBP.get()]))
15182  Vaxis_label = str(Vaxis_value)
15183  Bodeca.create_text(x1-3, y, text=Vaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
15184  if ShowCA_P.get() == 1 or ShowCB_P.get() == 1 or Show_Angle.get() == 1:
15185  Vaxis_value = ( 180 - ( i * (360 / Vdiv.get()))) + Phasecenter
15186  Vaxis_label = str(Vaxis_value)
15187  Bodeca.create_text(x2+3, y, text=Vaxis_label, fill=COLORtrace3, anchor="w", font=("arial", FontSize ))
15188  if NetworkScreenStatus.get() > 0:
15189  if Show_Rseries.get() == 1 or Show_Xseries.get() == 1 or Show_Magnitude.get() == 1:
15190  RperDiv = float(ResScale.get())
15191  Vaxis_value = ( (RperDiv * Vdiv.get()/2) - (i * RperDiv) ) + Impedcenter
15192  if Vaxis_value > 500 or Vaxis_value < -500:
15193  Vaxis_value = Vaxis_value/1000.0
15194  if Vaxis_value > 5 or Vaxis_value < -5:
15195  Vaxis_label = ' {0:.0f}'.format(Vaxis_value) + 'K'
15196  else:
15197  Vaxis_label = ' {0:.1f}'.format(Vaxis_value) + 'K'
15198  elif Vaxis_value > 50 or Vaxis_value < -50:
15199  Vaxis_label = ' {0:.1f} '.format(Vaxis_value)
15200  elif Vaxis_value > 5 or Vaxis_value < -55:
15201  Vaxis_label = ' {0:.2f} '.format(Vaxis_value)
15202  else:
15203  Vaxis_label = ' {0:.3f} '.format(Vaxis_value)
15204  Bodeca.create_text(x1-23, y, text=Vaxis_label, fill=COLORtrace5, anchor="e", font=("arial", FontSize ))
15205  i = i + 1
15206  # Draw vertical grid lines
15207  i = 0
15208  y1 = Y0TBP
15209  y2 = Y0TBP + GRHBP
15210  if HScaleBP.get() == 1:
15211  F = 1.0
15212  LogFStop = math.log10(EndFreq)
15213  try:
15214  LogFStart = math.log10(BeginFreq)
15215  except:
15216  LogFStart = 0.0
15217  LogFpixel = (LogFStop - LogFStart) / GRWBP
15218  # draw left and right edges
15219  while F <= EndFreq:
15220  if F >= BeginFreq:
15221  try:
15222  LogF = math.log10(F) # convet to log Freq
15223  x = x1 + (LogF - LogFStart)/LogFpixel
15224  except:
15225  x = x1
15226  Dline = [x,y1,x,y2]
15227  if F == 1 or F == 10 or F == 100 or F == 1000 or F == 10000 or F == 100000:
15228  Bodeca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
15229  axis_label = str(F)
15230  Bodeca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
15231  else:
15232  Bodeca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
15233 
15234  if F < 10:
15235  F = F + 1
15236  elif F < 100:
15237  F = F + 10
15238  elif F < 1000:
15239  F = F + 100
15240  elif F < 1000:
15241  F = F + 100
15242  elif F < 10000:
15243  F = F + 1000
15244  elif F < 100000:
15245  F = F + 10000
15246  elif F < 200000:
15247  F = F + 10000
15248  else:
15249  Freqdiv = (EndFreq - BeginFreq) / 10
15250  while (i < 11):
15251  x = x1 + i * GRWBP/10
15252  Dline = [x,y1,x,y2]
15253  if i == 0 or i == 10:
15254  Bodeca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
15255  else:
15256  Bodeca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
15257  axis_value = BeginFreq + (i * Freqdiv)
15258  axis_label = str(axis_value)
15259  Bodeca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
15260  i = i + 1
15261  # Draw X - Y cursors if needed
15262  Fpixel = (EndFreq - BeginFreq) / GRWBP # Frequency step per screen pixel
15263  LogFStop = math.log10(EndFreq)
15264  try:
15265  LogFStart = math.log10(BeginFreq)
15266  except:
15267  LogFStart = 0.0
15268  LogFpixel = (LogFStop - LogFStart) / GRWBP
15269  if ShowBPCur.get() > 0:
15270  Dline = [BPCursor, Y0TBP, BPCursor, Y0TBP+GRHBP]
15271  Bodeca.create_line(Dline, dash=(3,4), fill=COLORtrigger, width=GridWidth.get())
15272  # Horizontal conversion factors (frequency Hz) and border limits
15273  if HScaleBP.get() == 1:
15274  xfreq = 10**(((BPCursor-x1)*LogFpixel) + LogFStart)
15275  else:
15276  xfreq = ((BPCursor-x1)*Fpixel)+BeginFreq
15277  XFString = ' {0:.2f} '.format(xfreq)
15278  V_label = XFString + " Hz"
15279  Bodeca.create_text(BPCursor, Y0TBP+GRHBP+6, text=V_label, fill=COLORtext, anchor="n", font=("arial", FontSize ))
15280  #Bodeca.create_text(BPCursor+1, BdBCursor-5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
15281 #
15282  if ShowBdBCur.get() > 0:
15283  Dline = [x1, BdBCursor, x1+GRWBP, BdBCursor]
15284  Bodeca.create_line(Dline, dash=(3,4), fill=COLORtrigger, width=GridWidth.get())
15285  if ShowBdBCur.get() == 1:
15286  # Vertical conversion factors (level dBs) and border limits
15287  Yconv = float(GRHBP) / (Vdiv.get() * DBdivlist[DBdivindexBP.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
15288  Yc = float(Y0TBP) + Yconv * (DBlevelBP.get()) # Yc is the 0 dBm position, can be outside the screen!
15289  yvdB = ((Yc-BdBCursor)/Yconv)
15290  VdBString = ' {0:.1f} '.format(yvdB)
15291  V_label = VdBString + " dBV"
15292  else:
15293  # Vertical conversion factors (level degrees) and border limits
15294  Yconv = float(GRHBP) / 360.0 # Conversion factors, Yconv is the number of screenpoints per degree
15295  Yc = float(Y0TBP) # Yc is the 180 degree position
15296  yvdB = 180 + ((Yc-BdBCursor)/Yconv) + Phasecenter
15297  VdBString = ' {0:.1f} '.format(yvdB)
15298  V_label = VdBString + " Deg"
15299  Bodeca.create_text(x1+GRWBP+1, BdBCursor, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
15300  #Bodeca.create_text(BPCursor+1, BdBCursor+5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
15301  #
15302  SmoothBool = SmoothCurvesBP.get()
15303  # Draw traces
15304  if len(TAFline) > 4: # Avoid writing lines with 1 coordinate
15305  # Write the trace CHA
15306  if OverRangeFlagA == 1:
15307  Bodeca.create_line(TAFline, fill=COLORsignalband, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15308  else:
15309  Bodeca.create_line(TAFline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15310  if ShowMarkerBP.get() == 1:
15311  Peak_label = ' {0:.2f} '.format(PeakdbA) + ',' + ' {0:.1f} '.format(PeakfreqA)
15312  Bodeca.create_text(PeakxA, PeakyA, text=Peak_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
15313  if len(TBFline) > 4: # Avoid writing lines with 1 coordinate
15314  # Write the trace CHB
15315  if OverRangeFlagB == 1:
15316  Bodeca.create_line(TBFline, fill=COLORsignalband, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15317  else:
15318  Bodeca.create_line(TBFline, fill=COLORtrace2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15319  if ShowMarkerBP.get() == 1:
15320  Peak_label = ' {0:.2f} '.format(PeakdbB) + ',' + ' {0:.1f} '.format(PeakfreqB)
15321  Bodeca.create_text(PeakxB, PeakyB, text=Peak_label, fill=COLORtrace2, anchor="w", font=("arial", FontSize ))
15322  if len(TAPline) > 4: # Avoid writing lines with 1 coordinate
15323  # Write the phase trace A-B
15324  Bodeca.create_line(TAPline, fill=COLORtrace3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15325  if len(TBPline) > 4: # Avoid writing lines with 1 coordinate
15326  # Write the phase trace A-B
15327  Bodeca.create_line(TBPline, fill=COLORtrace4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15328  if ShowCA_RdB.get() == 1 and len(TAFRline) > 4: # Write the ref trace A if active
15329  Bodeca.create_line(TAFRline, fill=COLORtraceR1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15330  if ShowMarkerBP.get() == 1:
15331  Peak_label = ' {0:.2f} '.format(PeakdbRA) + ',' + ' {0:.1f} '.format(PeakfreqRA)
15332  Bodeca.create_text(PeakxRA, PeakyRA, text=Peak_label, fill=COLORtraceR1, anchor="e", font=("arial", FontSize ))
15333  if ShowCB_RdB.get() == 1 and len(TBFRline) > 4: # Write the ref trace B if active
15334  Bodeca.create_line(TBFRline, fill=COLORtraceR2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15335  if ShowMarkerBP.get() == 1:
15336  Peak_label = ' {0:.2f} '.format(PeakdbRB) + ',' + ' {0:.1f} '.format(PeakfreqRB)
15337  Freqca.create_text(PeakxRB, PeakyRB, text=Peak_label, fill=COLORtraceR2, anchor="w", font=("arial", FontSize ))
15338  if ShowCA_RP.get() == 1 and len(TAPRline) > 4: # Write the ref trace A if active
15339  Bodeca.create_line(TAPRline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15340  if ShowCB_RP.get() == 1 and len(TBPRline) > 4: # Write the ref trace A if active
15341  Bodeca.create_line(TBPRline, fill=COLORtraceR4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15342  if ShowMathBP.get() > 0 and len(TBPMline) > 4: # Write the Math trace if active
15343  Bodeca.create_line(TBPMline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15344  if ShowMarkerBP.get() == 1:
15345  Peak_label = ' {0:.2f} '.format(PeakMdb) + ',' + ' {0:.1f} '.format(PeakfreqM)
15346  Bodeca.create_text(PeakxM, PeakyM, text=Peak_label, fill=COLORtrace5, anchor="w", font=("arial", FontSize ))
15347  if ShowRMathBP.get() == 1 and len(TBPRMline) > 4: # Write the ref math trace if active
15348  Bodeca.create_line(TBPRMline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15349  if ShowMarkerBP.get() == 1:
15350  Peak_label = ' {0:.2f} '.format(PeakRMdb) + ',' + ' {0:.1f} '.format(PeakfreqRM)
15351  Bodeca.create_text(PeakxRM, PeakyRM, text=Peak_label, fill=COLORtraceR5, anchor="w", font=("arial", FontSize ))
15352  if Show_Rseries.get() == 1 and len(TIARline) > 4:
15353  Bodeca.create_line(TIARline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15354  if Show_Xseries.get() == 1 and len(TIAXline) > 4:
15355  Bodeca.create_line(TIAXline, fill=COLORtrace6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15356  if Show_Magnitude.get() == 1 and len(TIAMagline) > 4:
15357  Bodeca.create_line(TIAMagline, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15358  if Show_Angle.get() == 1 and len(TIAAngline) > 4:
15359  Bodeca.create_line(TIAAngline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15360  if Show_RseriesRef.get() == 1 and len(RefIARline) > 4:
15361  Bodeca.create_line(RefIARline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15362  if Show_XseriesRef.get() == 1 and len(RefIAXline) > 4:
15363  Bodeca.create_line(RefIAXline, fill=COLORtraceR6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15364  if Show_MagnitudeRef.get() == 1 and len(RefIAMagline) > 4:
15365  Bodeca.create_line(RefIAMagline, fill=COLORtraceR7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15366  if Show_AngleRef.get() == 1 and len(RefIAAngline) > 4:
15367  Bodeca.create_line(RefIAAngline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15368 
15369  Dline = [CurrentFreqX, Y0TBP, CurrentFreqX, Y0TBP+GRHBP]
15370  Bodeca.create_line(Dline, dash=(2,2), fill=COLORgrid, width=GridWidth.get())
15371  if HScaleBP.get() == 1:
15372  xfreq = 10**(((CurrentFreqX-x1)*LogFpixel) + LogFStart)
15373  else:
15374  xfreq = ((CurrentFreqX-x1)*Fpixel)+BeginFreq
15375  XFString = ' {0:.0f} '.format(xfreq)
15376  V_label = XFString + " Hz"
15377  Bodeca.create_text(CurrentFreqX, Y0TBP+GRHBP+1, text=V_label, fill=COLORtext, anchor="n", font=("arial", FontSize ))
15378  # General information on top of the grid
15379 
15380  txt = " Sample rate: " + str(SAMPLErate)
15381  txt = txt + " FFT samples: " + str(SMPfft)
15382 
15383  txt = txt + " " + FFTwindowname
15384 
15385  x = X0LBP
15386  y = 12
15387  idTXT = Bodeca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
15388 
15389  # Start and stop frequency and dB/div and trace mode
15390  txt = str(BeginFreq) + " to " + str(EndFreq) + " Hz"
15391  txt = txt + " " + str(DBdivlist[DBdivindexBP.get()]) + " dB/div"
15392  txt = txt + " Level: " + str(DBlevelBP.get()) + " dB "
15393  txt = txt + " FFT Bandwidth =" + ' {0:.2f} '.format(FFTbandwidth)
15394 
15395  x = X0LBP
15396  y = Y0TBP+GRHBP+23
15397  idTXT = Bodeca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
15398 
15399  if FreqTraceMode.get() == 1:
15400  txt ="Normal mode "
15401 
15402  if FreqTraceMode.get() == 2:
15403  txt = "Peak hold mode "
15404 
15405  if FreqTraceMode.get() == 3:
15406  txt = "Power average mode (" + str(TRACEaverage.get()) + ") "
15407 
15408  if ZEROstuffing.get() > 0:
15409  txt = txt + "Zero Stuffing = " + str(ZEROstuffing.get())
15410  # Runstatus and level information
15411  if (RUNstatus.get() == 0):
15412  txt = txt + " Stopped "
15413  else:
15414  if BodeDisp.get() == 1:
15415  txt = txt + " Running "
15416  else:
15417  txt = txt + " Display off "
15418  if FSweepMode.get() > 0:
15419  txt = txt + " Freq Step = " + str(LoopNum.get())
15420  x = X0LBP
15421  y = Y0TBP+GRHBP+34
15422  IDtxt = Bodeca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
15423 
15424 # Impedance analyzer routines -----
15425 def UpdateIAAll(): # Update Data, trace and screen
15426  global FFTBuffA, FFTBuffB
15427  global SMPfft
15428 
15429  if len(FFTBuffA) < SMPfft and len(FFTBuffB) < SMPfft:
15430  return
15431 
15432  MakeIATrace() # Update the traces
15433  UpdateIAScreen() # Update the screen
15434 
15435 def UpdateIATrace(): # Update trace and screen
15436  MakeIATrace() # Update traces
15437  UpdateIAScreen() # Update the screen
15438 
15439 def UpdateIAScreen(): # Update screen with trace and text
15440  MakeIAScreen() # Update the screen
15441  root.update() # Activate updated screens
15442 #
15443 def DoImpedance():
15444 
15445 # Input Variables
15446  global PeakdbA, PeakdbB, PeakRelPhase, PeakdbAB
15447  #(VZ/VA)from vector voltmeter
15448  # global VVangle # angle in degrees between VZ and VA
15449  global RsystemEntry # resistance of series resistor or power divider
15450 # Computed outputs
15451  # global VVangleCosine # cosine of vector voltmeter angle
15452  global ImpedanceMagnitude # in ohms
15453  global ImpedanceAngle # in degrees
15454  global ImpedanceRseries, ImpedanceXseries # in ohms
15455  global IA_Ext_Conf
15456 
15457  DEG2RAD = (math.pi / 180.0)
15458  SMALL = 1E-20
15459  try:
15460  ResValue = float(RsystemEntry.get())
15461  except:
15462  ResValue = 1000.0
15463 
15464  VA = math.pow(10,(PeakdbA/20))
15465  VB = math.pow(10,(PeakdbB/20))
15466  VVangleCosine = math.cos(math.radians(PeakRelPhase))
15467  if IA_Ext_Conf.get() == 1:
15468  VAB = math.pow(10,(PeakdbAB/20))
15469  VZ = VAB # VZ=VA-VB
15470  # VI = VB
15471  else:
15472  VZ = VB # VZ=VB
15473  VI = math.sqrt(VA**2 + VZ**2 - 2*VA*VZ*VVangleCosine)
15474  costheta = (VA**2 + VI**2 - VZ**2)/(2 * VA * VI)
15475  Za = ResValue * VA / VI
15476  ImpedanceRseries = Za * costheta - ResValue
15477  ImpedanceMagnitude = ResValue * VZ / VI
15478  # don't try to take square root of a negative number)
15479  ImpedanceXseries = math.sqrt(abs(ImpedanceMagnitude**2 - ImpedanceRseries**2))
15480 
15481  if(PeakRelPhase < 0.0):
15482  ImpedanceXseries = -ImpedanceXseries
15483  if IA_Ext_Conf.get() == 1:
15484  ImpedanceRseries = -ImpedanceRseries
15485  ImpedanceAngle = math.atan2(ImpedanceXseries, ImpedanceRseries) / DEG2RAD
15486 #
15487 def MakeIATrace(): # Update the grid and trace
15488  global FFTmemoryA, FFTresultA, FFTresultAB, PhaseAB
15489  global FFTmemoryB, FFTresultB
15490  global PhaseA, PhaseB, PhaseMemoryA, PhaseMemoryB
15491  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB, PeakRelPhase, PeakdbAB
15492  global PeakxM, PeakyM, PeakMdb, PeakfreqM, PeakphaseA, PeakphaseB
15493  global PeakfreqA, PeakfreqB, GainCorEntry, PhaseCorEntry, PhaseCorrection
15494  global DBdivindex # Index value
15495  global DBdivlist # dB per division list
15496  global DBlevel # Reference level
15497  global GRHIA # Screenheight
15498  global GRWIA # Screenwidth
15499  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, SMPfft
15500  global STARTsample, STOPsample, LoopNum, FSweepMode
15501  global TRACEmode, Two_X_Sample, IA_Ext_Conf
15502  global T1Vline, T2Vline, TMline, T1Pline, T2Pline
15503  global Vdiv # Number of vertical divisions
15504  global X0LIA # Left top X value
15505  global Y0TIA # Left top Y value
15506  global ImpedanceMagnitude # in ohms
15507  global ImpedanceAngle # in degrees
15508  global ImpedanceRseries, ImpedanceXseries # in ohms
15509 
15510  # Set the TRACEsize variable
15511  TRACEsize = len(FFTresultA) # Set the trace length
15512 
15513  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1)
15514  # Horizontal conversion factors (frequency Hz) and border limits
15515  STARTsample = 0 # First sample in FFTresult[] that is used
15516  STARTsample = int(math.ceil(STARTsample)) # First within screen range
15517  if Two_X_Sample.get() == 0:
15518  STOPsample = (SAMPLErate * 0.45) / Fsample # Last sample in FFTresult[] that is used
15519  else:
15520  STOPsample = (SAMPLErate * 0.45) / Fsample
15521  STOPsample = int(math.floor(STOPsample)) # Last within screen range, math.floor actually not necessary, part of int
15522 #
15523  RMScorr = 1.0 / SMPfft # For VOLTAGE!
15524  Powcorr = RMScorr **2 # vpktage squared For POWER!
15525  try:
15526  GainCorrection = float(eval(GainCorEntry.get()))
15527  except:
15528  GainCorEntry.delete(0,END)
15529  GainCorEntry.insert(0, GainCorrection)
15530 
15531  try:
15532  PhaseCorrection = float(eval(PhaseCorEntry.get()))
15533  except:
15534  PhaseCorEntry.delete(0,END)
15535  PhaseCorEntry.insert(0, PhaseCorrection)
15536 
15537  MAXsample = TRACEsize # Just an out of range check
15538  if STARTsample > (MAXsample - 1):
15539  STARTsample = MAXsample - 1
15540 
15541  if STOPsample > MAXsample:
15542  STOPsample = MAXsample - 1
15543 
15544  n = STARTsample
15545  PeakfreqA = PeakfreqB = PeakfreqM = F = n * Fsample
15546  PeakphaseA = PhaseA[n]
15547  PeakphaseB = PhaseB[n]
15548  #PeakphaseAB = PhaseAB[n]
15549  PeakSample = n
15550 
15551  PeakdbA = 10 * math.log10(float(FFTresultA[n]))
15552  PeakdbB = 10 * math.log10(float(FFTresultB[n]))
15553  PeakMdb = PeakdbA - PeakdbB
15554  if IA_Ext_Conf.get() == 1:
15555  PeakdbAB = 10 * math.log10(float(FFTresultAB[n]))
15556  while n <= STOPsample:
15557  F = n * Fsample
15558  try:
15559  dbA = 10 * math.log10(float(FFTresultA[n])) # Convert power to DBs, except for log(0) error
15560  except:
15561  dbA = -200
15562  if dbA > PeakdbA:
15563  PeakdbA = dbA
15564  PeakfreqA = F
15565  PeakphaseA = PhaseA[n]
15566  PeakSample = n
15567 
15568  try:
15569  dbB = 10 * math.log10(float(FFTresultB[n]))
15570  except:
15571  dbB = -200
15572  if dbB > PeakdbB:
15573  PeakdbB = dbB
15574  PeakfreqB = F
15575  PeakphaseB = PhaseB[n]
15576 
15577  if IA_Ext_Conf.get() == 1:
15578  try:
15579  dbAB = 10 * math.log10(float(FFTresultAB[n]))
15580  except:
15581  dbAB = -200
15582  if dbAB > PeakdbAB:
15583  PeakdbAB = dbAB
15584  PeakphaseAB = PhaseAB[n]
15585  RelPhase = PhaseA[n]-PhaseB[n]
15586  if RelPhase > 180:
15587  RelPhase = RelPhase - 360
15588  elif RelPhase < -180:
15589  RelPhase = RelPhase + 360
15590  if Two_X_Sample.get() == 0:
15591  PhErr = 0.0018 * n * Fsample # calculate pahse error due half sample period offset
15592  RelPhase = RelPhase + PhErr - 12.0
15593  else:
15594  RelPhase = RelPhase - 9.0
15595  n = n + 1
15596  if IA_Ext_Conf.get() == 1:
15597  PeakRelPhase = PeakphaseAB-PeakphaseA
15598  else:
15599  PeakRelPhase = PeakphaseB-PeakphaseA
15600 #
15601  if PeakRelPhase > 180:
15602  PeakRelPhase = PeakRelPhase - 360
15603  elif PeakRelPhase < -180:
15604  PeakRelPhase = PeakRelPhase + 360
15605  if Two_X_Sample.get() == 0:
15606  PhErr = 0.0018 * PeakSample * Fsample # calculate pahse error due half sample period offset
15607  PeakRelPhase = PeakRelPhase + PhaseCorrection - PhErr # - 12
15608  else:
15609  PeakRelPhase = PeakRelPhase + PhaseCorrection
15610  PeakdbB = PeakdbB + GainCorrection
15611  DoImpedance()
15612 
15614 def MakeIAScreen(): # Update the screen with traces and text
15615  global CANVASheightIA, CANVASwidthIA, IAca, TIAMline, TIAMRline
15616  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
15617  global PeakxM, PeakyM, PeakMdb, PeakfreqM, Two_X_Sample
15618  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
15619  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
15620  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM
15621  global PeakphaseA, PeakphaseB, PeakRelPhase, PhaseCalEntry, CapZeroEntry
15622  global SmoothCurvesBP, TRACEwidth, GridWidth # The colors
15623  global COLORsignalband, COLORtext, COLORgrid, IASweepSaved
15624  global COLORtrace1, COLORtrace2, COLORtrace5, COLORtrace6
15625  global ResScale, DisplaySeries # Ohms per div
15626  global FFTwindow, FFTbandwidth, ZEROstuffing, FFTwindowname
15627  global X0LIA # Left top X value
15628  global Y0TIA # Left top Y value
15629  global GRWIA # Screenwidth
15630  global GRHIA # Screenheight
15631  global FontSize, IAGridType
15632  global RUNstatus # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
15633  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, OverRangeFlagA, OverRangeFlagB
15634  global SMPfft # number of FFT samples
15635  global TRACEaverage # Number of traces for averageing
15636  global FreqTraceMode # 1 normal 2 max 3 average
15637  global Vdiv # Number of vertical divisions
15638  global ImpedanceMagnitude # in ohms
15639  global ImpedanceAngle # in degrees
15640  global ImpedanceRseries, ImpedanceXseries, Cseries # in ohms / uF
15641  global LoopNum, NetworkScreenStatus, NSweepSeriesR, NSweepSeriesX, NSweepSeriesMag, NSweepSeriesAng
15642  global NSweepParallelR, NSweepParallelC, NSweepParallelL, NSweepSeriesC, NSweepSeriesC
15643 
15644  # Delete all items on the screen
15645  IAca.delete(ALL) # remove all items
15646  SmoothBool = SmoothCurvesBP.get()
15647  Cparallel = 0.0
15648  Rparallel = 0.0
15649  Lparallel = 0.0
15650  Radius = (GRWIA-X0LIA)/(1 + Vdiv.get()*2) # 11
15651  xright = 10 + GRWIA/2 + ( Vdiv.get() * Radius ) # 5
15652  OhmsperPixel = float(ResScale.get())/Radius
15653  TRadius = Radius * Vdiv.get() # 5
15654  xcenter = GRWIA/2
15655  ycenter = GRHIA/2
15656  if IAGridType.get() == 0:
15657  # Draw circular grid lines
15658  i = 1
15659  xcenter = GRWIA/2
15660  ycenter = GRHIA/2
15661  Radius = (GRWIA-X0LIA)/(1 + Vdiv.get()*2) # 11
15662  OhmsperPixel = float(ResScale.get())/Radius
15663  TRadius = Radius * Vdiv.get() # 5
15664  xright = 10 + xcenter + ( Vdiv.get() * Radius ) # 5
15665  while (i <= Vdiv.get()):
15666  x0 = xcenter - ( i * Radius )
15667  x1 = xcenter + ( i * Radius )
15668  y0 = ycenter - ( i * Radius )
15669  y1 = ycenter + ( i * Radius )
15670  axisvalue = float(ResScale.get()) * i
15671  if axisvalue >= 1000.0 or axisvalue <= -1000.0:
15672  axisvalue = axisvalue / 1000
15673  ResTxt = '{0:.1f}'.format(axisvalue)
15674  axis_label = str(ResTxt) + "K"
15675  elif axisvalue >= 100.0 or axisvalue <= -100.0:
15676  ResTxt = '{0:.1f}'.format(axisvalue)
15677  axis_label = str(ResTxt)
15678  elif axisvalue >= 10.0 or axisvalue <= -10.0:
15679  ResTxt = '{0:.2f}'.format(axisvalue)
15680  axis_label = str(ResTxt)
15681  else:
15682  ResTxt = '{0:.3f}'.format(axisvalue)
15683  axis_label = str(ResTxt)
15684  IAca.create_oval( x0, y0, x1, y1, outline=COLORgrid, width=GridWidth.get())
15685  IAca.create_line(xcenter, y0, xright, y0, fill=COLORgrid, width=GridWidth.get(), dash=(4,3))
15686  IAca.create_text(xright, y0, text=axis_label, fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
15687  #
15688  i = i + 1
15689  IAca.create_line(xcenter, y0, xcenter, y1, fill=COLORgrid, width=GridWidth.get())
15690  IAca.create_line(x0, ycenter, x1, ycenter, fill=COLORgrid, width=GridWidth.get())
15691  RAngle = math.radians(45)
15692  y = TRadius*math.sin(RAngle)
15693  x = TRadius*math.cos(RAngle)
15694  IAca.create_line(xcenter-x, ycenter-y, xcenter+x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
15695  IAca.create_line(xcenter+x, ycenter-y, xcenter-x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
15696  IAca.create_text(x0, ycenter, text="180", fill=COLORgrid, anchor="e", font=("arial", FontSize+2 ))
15697  IAca.create_text(x1, ycenter, text="0.0", fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
15698  IAca.create_text(xcenter, y0, text="90", fill=COLORgrid, anchor="s", font=("arial", FontSize+2 ))
15699  IAca.create_text(xcenter, y1, text="-90", fill=COLORgrid, anchor="n", font=("arial", FontSize+2 ))
15700  else:
15701  # Draw horizontal grid lines
15702  i = 0 - Vdiv.get()
15703  j = 0
15704  x1 = X0LIA
15705  x2 = X0LIA + TRadius * 2
15706  xcenter = x1 + (TRadius)
15707  OhmsperPixel = float(ResScale.get())/Radius
15708  while (i <= Vdiv.get()):
15709  y = Y0TIA + j * (TRadius/Vdiv.get())
15710  Dline = [x1,y,x2,y]
15711  if i == 0 or i == Vdiv.get() or i == -Vdiv.get():
15712  IAca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
15713  else:
15714  IAca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
15715  axisvalue = float(ResScale.get()) * -i
15716  if axisvalue >= 1000.0 or axisvalue <= -1000.0:
15717  axisvalue = axisvalue / 1000
15718  ResTxt = '{0:.1f}'.format(axisvalue)
15719  axis_label = str(ResTxt) + "K"
15720  else:
15721  ResTxt = '{0:.0f}'.format(axisvalue)
15722  axis_label = str(ResTxt)
15723  IAca.create_text(x1-3, y, text=axis_label, fill=COLORtrace6, anchor="e", font=("arial", FontSize ))
15724  i = i + 1
15725  j = j + 1
15726  # Draw vertical grid lines
15727  i = 0 - Vdiv.get()
15728  j = 0
15729  y1 = Y0TIA
15730  y2 = Y0TIA + TRadius * 2
15731  ycenter = y1 + (TRadius)
15732  # "\n".join(axis_label)
15733  while (i <= Vdiv.get()): #
15734  x = x1 + j * (TRadius/Vdiv.get())
15735  Dline = [x,y1,x,y2]
15736  if i == 0 or i == Vdiv.get() or i == -Vdiv.get():
15737  IAca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
15738  else:
15739  IAca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
15740  axisvalue = float(ResScale.get()) * i
15741  if axisvalue >= 1000.0 or axisvalue <= -1000.0:
15742  axisvalue = axisvalue / 1000
15743  ResTxt = '{0:.1f}'.format(axisvalue)
15744  axis_label = str(ResTxt) + "K"
15745  else:
15746  ResTxt = '{0:.0f}'.format(axisvalue)
15747  axis_label = str(ResTxt)
15748  IAca.create_text(x, y2+3, text=axis_label, fill=COLORtrace1, anchor="n", font=("arial", FontSize ))
15749  i = i + 1
15750  j = j + 1
15751 # Draw traces
15752  # Add saved line if there
15753  if IASweepSaved.get() > 0:
15754  if len(TIAMRline) > 4:
15755  IAca.create_line(TIAMRline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15756 #
15757  x1 = xcenter + ( ImpedanceRseries / OhmsperPixel )
15758  if x1 > 1500:
15759  x1 = xright
15760  elif x1 < -500:
15761  x1 = xcenter - xright
15762  IAca.create_line(xcenter, ycenter, x1, ycenter, fill=COLORtrace1, arrow="last", width=TRACEwidth.get())
15763  y1 = ycenter - ( ImpedanceXseries / OhmsperPixel )
15764  if y1 > 1500:
15765  y1 = xright
15766  elif y1 < -500:
15767  y1 = ycenter - xright
15768  xmag = x1
15769  ymag = y1
15770  IAca.create_line(xcenter, ycenter, xcenter, y1, fill=COLORtrace6, arrow="last", width=TRACEwidth.get())
15771  MagRadius = ImpedanceMagnitude / OhmsperPixel
15772  y1 = ycenter - MagRadius*math.sin(math.radians(ImpedanceAngle))
15773  if y1 > 1500:
15774  y1 = xright
15775  elif y1 < -500:
15776  y1 = ycenter - xright
15777  x1 = xcenter + MagRadius*math.cos(math.radians(ImpedanceAngle))
15778  if x1 > 1500:
15779  x1 = xright
15780  elif x1 < -500:
15781  x1 = xcenter - xright
15782  IAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace2, arrow="last", width=TRACEwidth.get())
15783 #
15784  TIAMline = []
15785  if len(NSweepSeriesMag) > 2:
15786  index = 0
15787  while index < len(NSweepSeriesMag):
15788  MagRadius = NSweepSeriesMag[index] / OhmsperPixel
15789  y1 = ycenter - MagRadius*math.sin(math.radians(NSweepSeriesAng[index]))
15790  if y1 > 1500:
15791  y1 = xright
15792  elif y1 < -500:
15793  y1 = ycenter - xright
15794  x1 = xcenter + MagRadius*math.cos(math.radians(NSweepSeriesAng[index]))
15795  if x1 > 1500:
15796  x1 = xright
15797  elif x1 < -500:
15798  x1 = xcenter - xright
15799  TIAMline.append(x1)
15800  TIAMline.append(y1)
15801  index = index + 1
15802  IAca.create_line(TIAMline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15803 # display warning if input out of range
15804  if OverRangeFlagA == 1:
15805  x = X0LIA+GRWIA+10
15806  y = Y0TIA+GRHIA-40
15807  IAca.create_rectangle(x-6, y-6, x+6, y+6, fill="#ff0000")
15808  IAca.create_text (x+12, y, text="CHA Over Range", anchor=W, fill="#ff0000", font=("arial", FontSize+4 ))
15809  if OverRangeFlagB == 1:
15810  x = X0LIA+GRWIA+10
15811  y = Y0TIA+GRHIA-10
15812  IAca.create_rectangle(x-6, y-6, x+6, y+6, fill="#ff0000")
15813  IAca.create_text (x+12, y, text="CHB Over Range", anchor=W, fill="#ff0000", font=("arial", FontSize+4 ))
15814  # General information on top of the grid
15815 
15816  txt = " Sample rate: " + str(SAMPLErate)
15817  txt = txt + " FFT samples: " + str(SMPfft)
15818 
15819  txt = txt + " " + FFTwindowname
15820  if NetworkScreenStatus.get() > 0:
15821  txt = txt + " Sweep ON"
15822  else:
15823  txt = txt + " Sweep OFF"
15824  x = X0LIA
15825  y = 12
15826  idTXT = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
15827  #
15828  x = X0LIA + GRWIA + 4
15829  y = 24
15830  txt = "Gain " + ' {0:.2f} '.format(PeakdbB-PeakdbA) + " dB"
15831  TXT9 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15832  y = y + 24
15833  txt = "Phase " + ' {0:.2f} '.format(PeakRelPhase) + " Degrees"
15834  TXT10 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15835  y = y + 24
15836  txt = "Freq " + ' {0:.1f} '.format(PeakfreqA) + " Hertz"
15837  TXT11 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15838  y = y + 24
15839  txt = "Impedance Magnitude"
15840  TXT1 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15841  y = y + 24
15842  if ImpedanceMagnitude >= 1000.0 or ImpedanceMagnitude <= -1000.0:
15843  txt = '{0:.2f}'.format(ImpedanceMagnitude/1000.0)
15844  txt = str(txt) + "K"
15845  elif ImpedanceMagnitude >= 100.0 or ImpedanceMagnitude <= -100.0:
15846  txt = ' {0:.1f} '.format(ImpedanceMagnitude)
15847  elif ImpedanceMagnitude >= 10.0 or ImpedanceMagnitude <= -10.0:
15848  txt = ' {0:.2f} '.format(ImpedanceMagnitude)
15849  else:
15850  txt = ' {0:.3f} '.format(ImpedanceMagnitude)
15851  TXT2 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15852  y = y + 24
15853  txt = "Impedance Angle"
15854  TXT3 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15855  y = y + 24
15856  txt = ' {0:.1f} '.format(ImpedanceAngle)
15857  TXT4 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15858  y = y + 24
15859  txt = "Impedance R series"
15860  TXT5 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15861  y = y + 24
15862  if ImpedanceRseries >= 1000.0 or ImpedanceRseries <= -1000.0:
15863  txt = '{0:.2f}'.format(ImpedanceRseries/1000.0)
15864  txt = str(txt) + "K"
15865  elif ImpedanceRseries >= 100.0 or ImpedanceRseries <= -100.0:
15866  txt = ' {0:.1f} '.format(ImpedanceRseries)
15867  elif ImpedanceRseries >= 10.0 or ImpedanceRseries <= -10.0:
15868  txt = ' {0:.2f} '.format(ImpedanceRseries)
15869  else:
15870  txt = ' {0:.3f} '.format(ImpedanceRseries)
15871  TXT6 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15872  y = y + 24
15873  txt = "Impedance X series"
15874  TXT7 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15875  y = y + 24
15876  if ImpedanceXseries >= 1000.0 or ImpedanceXseries <= -1000.0:
15877  txt = '{0:.2f}'.format(ImpedanceXseries/1000.0)
15878  txt = str(txt) + "K"
15879  elif ImpedanceXseries >= 100.0 or ImpedanceXseries <= -100.0:
15880  txt = ' {0:.1f} '.format(ImpedanceXseries)
15881  elif ImpedanceXseries >= 10.0 or ImpedanceXseries <= -10.0:
15882  txt = ' {0:.2f} '.format(ImpedanceXseries)
15883  else:
15884  txt = ' {0:.3f} '.format(ImpedanceXseries)
15885  TXT8 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15886 #
15887  Cseries = 0.0
15888  Cparallel = 0.0
15889  Lseries = 0.0
15890  Lparallel = 0.0
15891  Rparallel = 0.0
15892  if ImpedanceXseries < 0: # calculate series capacitance
15893  y = y + 24
15894  try:
15895  Cseries = -1 / ( 2 * math.pi * PeakfreqA * ImpedanceXseries ) # in farads
15896  except:
15897  Cseries = 0
15898  Qseries = 1/(2*math.pi*PeakfreqA*Cseries*ImpedanceRseries)
15899  Cparallel = Cseries * (Qseries**2 / (1+Qseries**2))
15900  Cparallel = Cparallel * 1E6 # convert to micro Farads
15901  Rparallel = ImpedanceRseries * (1+Qseries**2)
15902  Cseries = Cseries * 1E6 # convert to micro Farads
15903  if DisplaySeries.get() == 0:
15904  txt = "Series Capacitance"
15905  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15906  y = y + 20
15907  if Cseries < 1:
15908  Ctext = Cseries * 1E3
15909  if Ctext < 1:
15910  Ctext = Ctext * 1E3
15911  CtextDis = Ctext + float(CapZeroEntry.get())
15912  txt = ' {0:.1f} '.format(CtextDis) + "pF"
15913  else:
15914  txt = ' {0:.3f} '.format(Ctext) + "nF"
15915  else:
15916  txt = ' {0:.3f} '.format(Cseries) + "uF"
15917  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15918  else:
15919  txt = "Parallel"
15920  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15921  y = y + 20
15922  if Cparallel < 1:
15923  Ctext = Cparallel * 1E3
15924  if Ctext < 1:
15925  Ctext = Ctext * 1E3
15926  txt = "Capacitance " + ' {0:.1f} '.format(Ctext) + "pF"
15927  else:
15928  txt = "Capacitance " + ' {0:.3f} '.format(Ctext) + "nF"
15929  else:
15930  txt = "Capacitance " + ' {0:.3f} '.format(Cparallel) + "uF"
15931  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15932  y = y + 20
15933  txt = "Resistance" + ' {0:.1f} '.format(Rparallel) + "ohms"
15934  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15935  y = y + 20
15936  dissp = abs(ImpedanceRseries/ImpedanceXseries) * 100 # Dissipation factor is ratio of XR to XC in percent
15937  txt = 'D = {0:.2f} '.format(dissp) + " %"
15938  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15939 
15940  elif ImpedanceXseries > 0: # calculate series inductance
15941  y = y + 24
15942  try:
15943  Lseries = ImpedanceXseries / ( 2 * 3.14159 * PeakfreqA ) # in henry
15944  except:
15945  Lseries = 0
15946  Qseries = (2*math.pi*PeakfreqA*Lseries)/ImpedanceRseries
15947  if Qseries == 0.0: # Check if divide by zero
15948  Qseries = 0.00001
15949  Lparallel = Lseries * ((1+Qseries**2) / Qseries**2)
15950  Lparallel = Lparallel * 1E3 # convert to millihenry
15951  Rparallel = ImpedanceRseries * (1+Qseries**2)
15952  Lseries = Lseries * 1E3 # in millihenry
15953  if DisplaySeries.get() == 0:
15954  txt = "Series Inductance"
15955  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15956  y = y + 22
15957  if Lseries < 1:
15958  Ltext = Lseries * 1E3
15959  txt = ' {0:.2f} '.format(Ltext) + "uH"
15960  else:
15961  txt = ' {0:.2f} '.format(Lseries) + "mH"
15962  IAca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15963  else:
15964  txt = "Parallel"
15965  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15966  y = y + 20
15967  if Lparallel < 1:
15968  Ltext = Lparallel * 1E3
15969  txt = "Inductance " + ' {0:.2f} '.format(Ltext) + "uH"
15970  else:
15971  txt = "Inductance " + ' {0:.2f} '.format(Lparallel) + "mH"
15972  IAca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15973  y = y + 20
15974  txt = "Resistance" + ' {0:.1f} '.format(Rparallel) + "ohms"
15975  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15976  y = y + 20
15977  qf = abs(ImpedanceXseries/ImpedanceRseries) * 100 # Quality Factor is ratio of XL to XR
15978  txt = 'Q = {0:.2f} '.format(qf)
15979  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15980  #
15981  if LoopNum.get() > 1:
15982  if NetworkScreenStatus.get() > 0:
15983  NSweepSeriesR.append(ImpedanceRseries)
15984  NSweepSeriesX.append(ImpedanceXseries)
15985  NSweepSeriesMag.append(ImpedanceMagnitude) # in ohms
15986  NSweepSeriesAng.append(ImpedanceAngle) # in degrees
15987  NSweepParallelR.append(Rparallel)
15988  NSweepParallelC.append(Cparallel) # in uF
15989  NSweepParallelL.append(Lparallel) # in mH
15990  NSweepSeriesC.append(Cseries) # in uF
15991  NSweepSeriesL.append(Lseries) # in mH
15992  # Start and stop frequency and trace mode
15993  Fmax = int(SAMPLErate * 0.45)
15994  txt = "0.0 to " + str(Fmax) + " Hz"
15995 
15996  txt = txt + " FFT Bandwidth =" + ' {0:.2f} '.format(FFTbandwidth)
15997 
15998  x = X0LIA
15999  y = Y0TIA+GRHIA-13
16000  idTXT = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
16001  txt = " "
16002  if FreqTraceMode.get() == 1:
16003  txt ="Normal mode "
16004 
16005  if FreqTraceMode.get() == 2:
16006  txt = "Peak hold mode "
16007 
16008  if FreqTraceMode.get() == 3:
16009  txt = "Power average mode (" + str(TRACEaverage.get()) + ") "
16010 
16011  if ZEROstuffing.get() > 0:
16012  txt = txt + "Zero Stuffing = " + str(ZEROstuffing.get())
16013  # Runstatus and level information
16014  if (RUNstatus.get() == 0):
16015  txt = txt + " Stopped "
16016  else:
16017  txt = txt + " Running "
16018  y = Y0TIA+GRHIA
16019  IDtxt = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
16020 #
16021 def IACaresize(event):
16022  global IAca, GRWIA, XOLIA, GRHIA, Y0TIA, CANVASwidthIA, CANVASheightIA, FontSize
16023 
16024  CANVASwidthIA = event.width - 4
16025  CANVASheightIA = event.height - 4
16026  GRWIA = CANVASwidthIA - (2 * X0LIA) - int(21.25 * FontSize) # 170 new grid width
16027  GRHIA = CANVASheightIA - Y0TIA - int(2.25 * FontSize) # 10 new grid height
16028  UpdateIAAll()
16029 #
16030 # ================ Make IA Window ==========================
16031 def MakeIAWindow():
16032  global iawindow, IAca, logo, IAScreenStatus, RsystemEntry, IADisp, AWGSync, IASource
16033  global COLORcanvas, CANVASwidthIA, CANVASheightIA, RevDate, AWGAMode, AWGAShape, AWGBMode, AWG_2X
16034  global FFTwindow, CutDC, ColorMode, ResScale, GainCorEntry, PhaseCorEntry, DisplaySeries
16035  global GRWIA, X0LIA, GRHIA, Y0TIA, IA_Ext_Conf, DeBugMode, SWRev, CapZeroEntry
16036  global NetworkScreenStatus, IASweepSaved, IAGridType
16037  global FrameRefief, BorderSize
16038 
16039  if IAScreenStatus.get() == 0:
16040  IAScreenStatus.set(1)
16041  IADisp.set(1)
16042  IACheckBox()
16043  CutDC.set(1) # set to remove DC
16044  CANVASwidthIA = GRWIA + 2 * X0LIA + int(21.25 * FontSize) # The canvas width
16045  CANVASheightIA = GRHIA + Y0TIA + int(2.25 * FontSize) # The canvas height
16046  AWGAMode.set(0) # Set AWG A to SVMI
16047  AWGAShape.set(18) # Set Shape to Bode Sine
16048  ReMakeAWGwaves()
16049  if AWG_2X.get == 1:
16050  AWGBMode.set(0) # Set AWG B to SVMI
16051  else:
16052  AWGBMode.set(2) # Set AWG B to Hi-Z
16053  BAWGAModeLabel()
16054  BAWGBModeLabel()
16055  AWGSync.set(1) # Set AWGs to run sync
16056  iawindow = Toplevel()
16057  iawindow.title("Impedance Analyzer " + SWRev + RevDate)
16058  iawindow.protocol("WM_DELETE_WINDOW", DestroyIAScreen)
16059  frame2iar = Frame(iawindow, borderwidth=BorderSize, relief=FrameRefief)
16060  frame2iar.pack(side=RIGHT, expand=NO, fill=BOTH)
16061 
16062  frame2ia = Frame(iawindow, borderwidth=BorderSize, relief=FrameRefief)
16063  frame2ia.pack(side=TOP, expand=YES, fill=BOTH)
16064 
16065  IAca = Canvas(frame2ia, width=CANVASwidthIA, height=CANVASheightIA, background=COLORcanvas, cursor='cross')
16066  IAca.bind("<Configure>", IACaresize)
16067  IAca.bind("<Return>", DoNothing)
16068  IAca.bind("<space>", onCanvasSpaceBar)
16069  IAca.pack(side=TOP, expand=YES, fill=BOTH)
16070 
16071  # menu buttons
16072  # right side drop down menu buttons
16073  dropmenu = Frame( frame2iar )
16074  dropmenu.pack(side=TOP)
16075  # File menu
16076  IAFilemenu = Menubutton(dropmenu, text="File", style="W5.TButton")
16077  IAFilemenu.menu = Menu(IAFilemenu, tearoff = 0 )
16078  IAFilemenu["menu"] = IAFilemenu.menu
16079  IAFilemenu.menu.add_command(label="Save Config", command=BSaveConfigIA)
16080  IAFilemenu.menu.add_command(label="Load Config", command=BLoadConfigIA)
16081  IAFilemenu.menu.add_command(label="Run Script", command=RunScript)
16082  IAFilemenu.menu.add_command(label="Save V Cal", command=BSaveCal)
16083  IAFilemenu.menu.add_command(label="Load V Cal", command=BLoadCal)
16084  IAFilemenu.menu.add_command(label="Save Data", command=BSaveDataIA)
16085  IAFilemenu.menu.add_command(label="Save Screen", command=BSaveScreenIA)
16086  IAFilemenu.menu.add_command(label="Help", command=BHelp)
16087  IAFilemenu.pack(side=LEFT, anchor=W)
16088  #
16089  IAOptionmenu = Menubutton(dropmenu, text="Options", style="W8.TButton")
16090  IAOptionmenu.menu = Menu(IAOptionmenu, tearoff = 0 )
16091  IAOptionmenu["menu"] = IAOptionmenu.menu
16092  IAOptionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
16093  IAOptionmenu.menu.add_command(label='Set Sample Rate', command=MakeSampleRateMenu) # SetSampleRate)
16094  IAOptionmenu.menu.add_checkbutton(label='Cut-DC', variable=CutDC)
16095  IAOptionmenu.menu.add_checkbutton(label='Sweep-on', variable=NetworkScreenStatus)
16096  IAOptionmenu.menu.add_checkbutton(label='Save Sweep', variable=IASweepSaved, command=BSaveIASweep)
16097  if DeBugMode == 1:
16098  IAOptionmenu.menu.add_command(label="-Ext Config-", command=donothing)
16099  IAOptionmenu.menu.add_radiobutton(label='1', variable=IA_Ext_Conf, value=0)
16100  IAOptionmenu.menu.add_radiobutton(label='2', variable=IA_Ext_Conf, value=1)
16101  IAOptionmenu.menu.add_command(label="-Meas As-", command=donothing)
16102  IAOptionmenu.menu.add_radiobutton(label='Series', variable=DisplaySeries, value=0)
16103  IAOptionmenu.menu.add_radiobutton(label='Parallel', variable=DisplaySeries, value=1)
16104  IAOptionmenu.menu.add_command(label="-Background-", command=donothing)
16105  IAOptionmenu.menu.add_radiobutton(label='Black', variable=ColorMode, value=0, command=BgColor)
16106  IAOptionmenu.menu.add_radiobutton(label='White', variable=ColorMode, value=1, command=BgColor)
16107  IAOptionmenu.pack(side=LEFT, anchor=W)
16108  #
16109  rsemenu = Frame( frame2iar )
16110  rsemenu.pack(side=TOP)
16111  rseb2 = Button(rsemenu, text="Stop", style="Stop.TButton", command=BStop)
16112  rseb2.pack(side=RIGHT)
16113  rseb3 = Button(rsemenu, text="Run", style="Run.TButton", command=BStartIA)
16114  rseb3.pack(side=RIGHT)
16115  #
16116  IAFFTwindmenu = Menubutton(frame2iar, text="FFTwindow", style="W11.TButton")
16117  IAFFTwindmenu.menu = Menu(IAFFTwindmenu, tearoff = 0 )
16118  IAFFTwindmenu["menu"] = IAFFTwindmenu.menu
16119  IAFFTwindmenu.menu.add_radiobutton(label='Rectangular window (B=1)', variable=FFTwindow, value=0)
16120  IAFFTwindmenu.menu.add_radiobutton(label='Cosine window (B=1.24)', variable=FFTwindow, value=1)
16121  IAFFTwindmenu.menu.add_radiobutton(label='Triangular window (B=1.33)', variable=FFTwindow, value=2)
16122  IAFFTwindmenu.menu.add_radiobutton(label='Hann window (B=1.5)', variable=FFTwindow, value=3)
16123  IAFFTwindmenu.menu.add_radiobutton(label='Blackman window (B=1.73)', variable=FFTwindow, value=4)
16124  IAFFTwindmenu.menu.add_radiobutton(label='Nuttall window (B=2.02)', variable=FFTwindow, value=5)
16125  IAFFTwindmenu.menu.add_radiobutton(label='Flat top window (B=3.77)', variable=FFTwindow, value=6)
16126  IAFFTwindmenu.pack(side=TOP)
16127  #
16128  smpmenu = Frame( frame2iar )
16129  smpmenu.pack(side=TOP)
16130  smpb1 = Button(smpmenu, text="-Samples", style="W8.TButton", command=Bsamples1)
16131  smpb1.pack(side=LEFT)
16132  smpb2 = Button(smpmenu, text="+Samples", style="W8.TButton", command=Bsamples2)
16133  smpb2.pack(side=LEFT)
16134  # Temp set source resistance to 1000
16135  rsystem = Frame( frame2iar )
16136  rsystem.pack(side=TOP)
16137  rsystemlab = Label(rsystem, text="Ext Res")
16138  rsystemlab.pack(side=LEFT, anchor=W)
16139  RsystemEntry = Entry(rsystem, width=7, cursor='double_arrow')
16140  RsystemEntry.bind('<Return>', onTextKey)
16141  RsystemEntry.bind('<MouseWheel>', onTextScroll)
16142  RsystemEntry.bind("<Button-4>", onTextScroll)# with Linux OS
16143  RsystemEntry.bind("<Button-5>", onTextScroll)
16144  RsystemEntry.bind('<Key>', onTextKey)
16145  RsystemEntry.pack(side=LEFT, anchor=W)
16146  RsystemEntry.delete(0,"end")
16147  RsystemEntry.insert(4,1000)
16148  # Res Scale Spinbox
16149  ressb = Frame( frame2iar )
16150  ressb.pack(side=TOP)
16151  reslab = Label(ressb, text="Ohms/div ")
16152  reslab.pack(side=LEFT)
16153  ResScale = Spinbox(ressb, width=7, cursor='double_arrow', values=ResScalediv)
16154  ResScale.bind('<MouseWheel>', onSpinBoxScroll)
16155  ResScale.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
16156  ResScale.bind("<Button-5>", onSpinBoxScroll)
16157  ResScale.pack(side=LEFT)
16158  ResScale.delete(0,"end")
16159  ResScale.insert(0,500)
16160  #
16161  GainCor = Frame( frame2iar )
16162  GainCor.pack(side=TOP)
16163  GainCorlab = Label(GainCor, text="Gain Cor dB")
16164  GainCorlab.pack(side=LEFT, anchor=W)
16165  GainCorEntry = Entry(GainCor, width=7, cursor='double_arrow')
16166  GainCorEntry.bind('<Return>', onTextKey)
16167  GainCorEntry.bind('<MouseWheel>', onTextScroll)
16168  GainCorEntry.bind("<Button-4>", onTextScroll)# with Linux OS
16169  GainCorEntry.bind("<Button-5>", onTextScroll)
16170  GainCorEntry.bind('<Key>', onTextKey)
16171  GainCorEntry.pack(side=LEFT, anchor=W)
16172  GainCorEntry.delete(0,"end")
16173  GainCorEntry.insert(4,0.0)
16174  #
16175  PhaseCor = Frame( frame2iar )
16176  PhaseCor.pack(side=TOP)
16177  PhaseCorlab = Label(PhaseCor, text="Phase Cor")
16178  PhaseCorlab.pack(side=LEFT, anchor=W)
16179  PhaseCorEntry = Entry(PhaseCor, width=7, cursor='double_arrow')
16180  PhaseCorEntry.bind('<Return>', onTextKey)
16181  PhaseCorEntry.bind('<MouseWheel>', onTextScroll)
16182  PhaseCorEntry.bind("<Button-4>", onTextScroll)# with Linux OS
16183  PhaseCorEntry.bind("<Button-5>", onTextScroll)
16184  PhaseCorEntry.bind('<Key>', onTextKey)
16185  PhaseCorEntry.pack(side=LEFT, anchor=W)
16186  PhaseCorEntry.delete(0,"end")
16187  PhaseCorEntry.insert(4,0.0)
16188  #
16189  capofflab = Label(frame2iar, text="Capacitance Offset")
16190  capofflab.pack(side=TOP)
16191  CapZero = Frame( frame2iar )
16192  CapZero.pack(side=TOP)
16193  CapZerobutton = Button(CapZero, text="Zero", style="W4.TButton", command=IACapZero)
16194  CapZerobutton.pack(side=LEFT, anchor=W)
16195  CapResetbutton = Button(CapZero, text="Reset", style="W5.TButton", command=IACapReset)
16196  CapResetbutton.pack(side=LEFT, anchor=W)
16197  CapZeroEntry = Entry(CapZero, width=6, cursor='double_arrow')
16198  CapZeroEntry.bind('<Return>', onTextKey)
16199  CapZeroEntry.bind('<MouseWheel>', onTextScroll)
16200  CapZeroEntry.bind("<Button-4>", onTextScroll)# with Linux OS
16201  CapZeroEntry.bind("<Button-5>", onTextScroll)
16202  CapZeroEntry.bind('<Key>', onTextKey)
16203  CapZeroEntry.pack(side=LEFT, anchor=W)
16204  CapZeroEntry.delete(0,"end")
16205  CapZeroEntry.insert(4,0.0)
16206  #
16207  srclab = Label(frame2iar, text="Source")
16208  srclab.pack(side=TOP)
16209  extsrc1 = Radiobutton(frame2iar, text="Internal", variable=IASource, value=0, command=IASourceSet)
16210  extsrc1.pack(side=TOP)
16211  extsrc2 = Radiobutton(frame2iar, text="External", variable=IASource, value=1, command=IASourceSet)
16212  extsrc2.pack(side=TOP)
16213  #
16214  gridmenu = Frame( frame2iar )
16215  gridmenu.pack(side=TOP)
16216  iagrid1= Radiobutton(frame2iar, text="Polar Grid", variable=IAGridType, value=0) #, command=IAGridSet)
16217  iagrid1.pack(side=TOP)
16218  iagrid2 = Radiobutton(frame2iar, text="Rect Grid", variable=IAGridType, value=1) #, command=IAGridSet)
16219  iagrid2.pack(side=TOP)
16220  #
16221  dismiss1button = Button(frame2iar, text="Dismiss", style="W8.TButton", command=DestroyIAScreen)
16222  dismiss1button.pack(side=TOP)
16223  # add ADI logo
16224  ADI1 = Label(frame2iar, image=logo, anchor= "sw", compound="top") # height=49, width=116,
16225  ADI1.pack(side=TOP)
16226 #
16227 def DestroyIAScreen():
16228  global iawindow, IAScreenStatus, IAca, IADisp
16229 
16230  IAScreenStatus.set(0)
16231  IADisp.set(0)
16232  IACheckBox()
16233  iawindow.destroy()
16234 #
16235 def BSaveIASweep():
16236  global TIAMline, TIAMRline, IASweepSaved
16237 
16238  if IASweepSaved.get() > 0:
16239  TIAMRline = TIAMline
16240 #
16241 def IACapZero():
16242  global Cseries, CapZeroEntry
16243 
16244  Ctext = ' {0:.1f} '.format(-Cseries * 1E6)
16245  CapZeroEntry.delete(0,"end")
16246  CapZeroEntry.insert(6,Ctext)
16247 #
16248 def IACapReset():
16249  global CapZeroEntry
16250 
16251  CapZeroEntry.delete(0,"end")
16252  CapZeroEntry.insert(4,0.0)
16253 #
16254 def MakeNyquistPlot():
16255  global nqpwindow, NqPca, logo, NqPScreenStatus, NqPDisp
16256  global COLORcanvas, CANVASwidthNqP, CANVASheightNqP, RevDate
16257  global GRWNqP, X0LNqP, GRHNqP, Y0TNqP, DeBugMode, SWRev
16258  global NetworkScreenStatus, NqPSweepSaved
16259  global FrameRefief, BorderSize
16260 
16261  if NqPScreenStatus.get() == 0:
16262  NqPScreenStatus.set(1)
16263  NqPDisp.set(1)
16264  CANVASwidthNqP = GRWNqP + (2 * X0LNqP) # The canvas width
16265  CANVASheightNqP = GRHNqP + Y0TNqP + 10 # The canvas height
16266  nqpwindow = Toplevel()
16267  nqpwindow.title("Nyquist Plot " + SWRev + RevDate)
16268  nqpwindow.protocol("WM_DELETE_WINDOW", DestroyNqPScreen)
16269 
16270  frame2nqp = Frame(nqpwindow, borderwidth=BorderSize, relief=FrameRefief)
16271  frame2nqp.pack(side=TOP, expand=YES, fill=BOTH)
16272 
16273  NqPca = Canvas(frame2nqp, width=CANVASwidthNqP, height=CANVASheightNqP, background=COLORcanvas, cursor='cross')
16274  NqPca.bind("<Configure>", NqPCaresize)
16275  NqPca.bind("<Return>", DoNothing)
16276  NqPca.bind("<space>", onCanvasSpaceBar)
16277  NqPca.pack(side=TOP, expand=YES, fill=BOTH)
16278 #
16279 def DestroyNqPScreen():
16280  global nqpwindow, NqPScreenStatus, NqPca, NqPDisp
16281 
16282  NqPScreenStatus.set(0)
16283  NqPDisp.set(0)
16284  nqpwindow.destroy()
16285 #
16286 def NqPCaresize(event):
16287  global NqPca, GRWNqP, XOLNqP, GRHNqP, Y0TNqP, CANVASwidthNqP, CANVASheightNqP, FontSize
16288 
16289  CANVASwidthNqP = event.width - 4
16290  CANVASheightNqP = event.height - 4
16291  GRWNqP = CANVASwidthNqP - (2 * X0LNqP) # new grid width
16292  GRHNqP = CANVASheightNqP - Y0TNqP - int(1.25 * FontSize) # 10 new grid height
16293  UpdateNqPAll()
16294 
16296 def MakeNqPScreen():
16297  global NqPca, GRWNqP, XOLNqP, GRHNqP, Y0TNqP, CANVASwidthNqP, CANVASheightNqP, COLORtrace1
16298  global COLORgrid, GridWidth, SmoothCurvesBP, SmoothBool, DBlevelBP, DBdivlist, DBdivindexBP
16299  global FSweepAdB, FSweepBdB, FSweepBPh, FSweepAPh, ShowMathBP, NqPline, Two_X_Sample, TRACEwidth
16300  global Vdiv, FBins, FStep
16301  global FontSize
16302 
16303  # Delete all items on the canvas
16304  NqPca.delete(ALL) # remove all items
16305  SmoothBool = SmoothCurvesBP.get()
16306  # Draw circular grid lines
16307  i = 1
16308  xcenter = GRWNqP/2
16309  ycenter = GRHNqP/2
16310  Radius = (GRWNqP-X0LNqP)/(1 + Vdiv.get() * 2) # 11
16311  dBperPixel = float(DBdivlist[DBdivindexBP.get()])/Radius
16312  TRadius = Radius * Vdiv.get() # 5
16313  x1 = X0LNqP
16314  x2 = X0LNqP + GRWNqP
16315  xright = 10 + xcenter + ( Vdiv.get() * Radius ) # 5
16316  while (i <= Vdiv.get()):
16317  x0 = xcenter - ( i * Radius )
16318  x1 = xcenter + ( i * Radius )
16319  y0 = ycenter - ( i * Radius )
16320  y1 = ycenter + ( i * Radius )
16321  dBaxis_value = (DBlevelBP.get() - (i * DBdivlist[DBdivindexBP.get()]))
16322  NqPca.create_oval( x0, y0, x1, y1, outline=COLORgrid, width=GridWidth.get())
16323  NqPca.create_line(xcenter, y0, xright, y0, fill=COLORgrid, width=GridWidth.get(), dash=(4,3))
16324  NqPca.create_text(xright, y0, text=str(dBaxis_value), fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
16325  #
16326  i = i + 1
16327  NqPca.create_line(xcenter, y0, xcenter, y1, fill=COLORgrid, width=GridWidth.get())
16328  NqPca.create_line(x0, ycenter, x1, ycenter, fill=COLORgrid, width=GridWidth.get())
16329  RAngle = math.radians(45)
16330  y = TRadius*math.sin(RAngle)
16331  x = TRadius*math.cos(RAngle)
16332  NqPca.create_line(xcenter-x, ycenter-y, xcenter+x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
16333  NqPca.create_line(xcenter+x, ycenter-y, xcenter-x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
16334  NqPca.create_text(x0, ycenter, text="180", fill=COLORgrid, anchor="e", font=("arial", FontSize+2 ))
16335  NqPca.create_text(x1, ycenter, text="0.0", fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
16336  NqPca.create_text(xcenter, y0, text="90", fill=COLORgrid, anchor="s", font=("arial", FontSize+2 ))
16337  NqPca.create_text(xcenter, y1, text="-90", fill=COLORgrid, anchor="n", font=("arial", FontSize+2 ))
16338  # xcenter = xcenter + (DBlevelBP.get()/dBperPixel)
16339 # Draw traces
16340  NqPline = []
16341  if len(FSweepAdB) > 4:
16342  for index in range(len(FSweepAdB)): # while n < len(FStep):
16343  if index < len(FStep): # check if n has gone out off bounds because user did something dumb
16344  F = FBins[int(FStep[index])] # look up frequency bin in list of bins
16345  else:
16346  F = FBins[int(FStep[0])]
16347  # Mag value
16348  dbA = 10 * math.log10(float(FSweepAdB[index])) # Convert power to DBs, except for log(0) error
16349  dbB = 10 * math.log10(float(FSweepBdB[index]))
16350  if ShowMathBP.get() == 1:
16351  MdB = dbA - dbB
16352  elif ShowMathBP.get() == 2:
16353  MdB = dbB - dbA
16354  MagRadius = (-MdB / dBperPixel) + (DBlevelBP.get()/dBperPixel)
16355  # Phase Value
16356  RelPhase = FSweepBPh[index] - FSweepAPh[index]
16357  if RelPhase > 180:
16358  RelPhase = RelPhase - 360
16359  elif RelPhase < -180:
16360  RelPhase = RelPhase + 360
16361  if Two_X_Sample.get() == 0:
16362  PhErr = 0.0018 * F # calculate phase error due half sample period offset
16363  RelPhase = RelPhase - PhErr # - PhaseOffset1x # - 12.0
16364  else:
16365  RelPhase = RelPhase # - PhaseOffset2x # - 9.0
16366  y1 = ycenter - MagRadius*math.sin(math.radians(RelPhase))
16367  if y1 > 1500:
16368  y1 = xright
16369  elif y1 < -500:
16370  y1 = ycenter - xright
16371  x1 = xcenter + MagRadius*math.cos(math.radians(RelPhase ))
16372  if x1 > 1500:
16373  x1 = xright
16374  elif x1 < -500:
16375  x1 = xcenter - xright
16376  NqPline.append(x1)
16377  NqPline.append(y1)
16378  NqPca.create_line(NqPline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
16379 #
16380 def MakeNicPlot():
16381  global NiCScreenStatus, NiCDisp
16382  global nicwindow, NiCca, logo, SWRev
16383  global COLORcanvas, CANVASwidthNic, CANVASheightNic, RevDate
16384  global GRWNiC, X0LNiC, GRHNiC, Y0TNiC, DeBugMode
16385  global NetworkScreenStatus, NiCSweepSaved
16386  global FrameRefief, BorderSize
16387 
16388  if NiCScreenStatus.get() == 0:
16389  NiCScreenStatus.set(1)
16390  NiCDisp.set(1)
16391  CANVASwidthNic = GRWNiC + 18 + X0LNiC # The canvas width
16392  CANVASheightNic = GRHNiC + 60 # The canvas height
16393  nicwindow = Toplevel()
16394  nicwindow.title("Nichols Plot " + SWRev + RevDate)
16395  nicwindow.protocol("WM_DELETE_WINDOW", DestroyNiCScreen)
16396 
16397  frame2nic = Frame(nicwindow, borderwidth=BorderSize, relief=FrameRefief)
16398  frame2nic.pack(side=TOP, expand=YES, fill=BOTH)
16399 
16400  NiCca = Canvas(frame2nic, width=CANVASwidthNic, height=CANVASheightNic, background=COLORcanvas, cursor='cross')
16401  NiCca.bind("<Configure>", NiCCaresize)
16402  NiCca.bind("<Return>", DoNothing)
16403  NiCca.bind("<space>", onCanvasSpaceBar)
16404  NiCca.pack(side=TOP, expand=YES, fill=BOTH)
16405 #
16406 def DestroyNiCScreen():
16407  global nicwindow, NiCScreenStatus, NiCca, NiCDisp
16408 
16409  NiCScreenStatus.set(0)
16410  NiCDisp.set(0)
16411  nicwindow.destroy()
16412 #
16413 def NiCCaresize(event):
16414  global NiCca, GRWNiC, XOLNiC, GRHNiC, Y0TNiC, CANVASwidthNic, CANVASheightNic, FontSize
16415 
16416  CANVASwidthNic = event.width - 4
16417  CANVASheightNic = event.height - 4
16418  GRWNiC = CANVASwidthNic - int(2.25 * FontSize) - X0LNiC # 18 new grid width
16419  GRHNiC = CANVASheightNic - int(7.5 * FontSize) # 60 new grid height
16420  UpdateNiCAll()
16421 
16423 def MakeNiCScreen():
16424  global NiCline, NiCca, CANVASwidthNic, CANVASheightNic, X0LNiC, GRWNiC, Y0TNiC, GRHNiC, X0TNiC
16425  global COLORzeroline, GridWidth, COLORgrid, FSweepAdB, FSweepBdB, Two_X_Sample, ShowMathBP
16426  global FSweepBPh, FSweepAPh, SmoothCurvesBP, SmoothBool, DBlevelBP, DBdivlist, DBdivindexBP
16427  global Vdiv, FBins, FStep, PhCenBodeEntry, RelPhaseCenter
16428  global FontSize
16429 
16430  Ymin = Y0TNiC # Minimum position of XY grid (top)
16431  Ymax = Y0TNiC + GRHNiC # Maximum position of XY grid (bottom)
16432  Xmin = X0LNiC # Minimum position of XY grid (left)
16433  Xmax = X0LNiC + GRWNiC # Maximum position of XY grid (right)
16434  try:
16435  Phasecenter = int(PhCenBodeEntry.get())
16436  RelPhaseCenter.set(Phasecenter)
16437  except:
16438  PhCenBodeEntry.delete(0,"end")
16439  PhCenBodeEntry.insert(0,0)
16440  RelPhaseCenter.set(0)
16441  Phasecenter = 0
16442  # Delete all items on the screen
16443  MarkerNum = 0
16444  SmoothBool = SmoothCurvesBP.get()
16445  NiCca.delete(ALL) # remove all items
16446  # Draw horizontal grid lines Rel Gain Magnitude
16447  i = 0
16448  x1 = X0LNiC
16449  x2 = X0TNiC = X0LNiC + GRWNiC
16450  mg_siz = GRWNiC/10.0
16451  mg_inc = mg_siz/5.0
16452  DegPerDiv = 360 / 10
16453  while (i < Vdiv.get()+1):
16454  dBaxis_value = (DBlevelBP.get() - (i * DBdivlist[DBdivindexBP.get()]))
16455  y = Y0TNiC + i * GRHNiC/Vdiv.get()
16456  Dline = [x1,y,x2,y]
16457  if dBaxis_value == 0:
16458  NiCca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue line at center of grid
16459  k = 0
16460  while (k < 10):
16461  l = 1
16462  while (l < 5): # add tick marks
16463  Dline = [x1+k*mg_siz+l*mg_inc,y-5,x1+k*mg_siz+l*mg_inc,y+5]
16464  NiCca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
16465  l = l + 1
16466  k = k + 1
16467  else:
16468  NiCca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
16469  dBaxis_label = str(dBaxis_value)
16470  NiCca.create_text(x1-3, y, text=dBaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
16471 
16472  i = i + 1
16473  # Draw vertical grid lines (phase -180 to 180 10 div)
16474  i = 0
16475  y1 = Y0TNiC
16476  y2 = Y0TNiC + GRHNiC
16477  mg_siz = GRHNiC/10.0
16478  mg_inc = mg_siz/5.0
16479  #
16480  while (i < 11):
16481  x = X0LNiC + i * GRWNiC/10.0
16482  Dline = [x,y1,x,y2]
16483  axis_value = Phasecenter - 180 + (i * DegPerDiv)
16484  axis_label = str(axis_value)
16485  if ( axis_value == 0):
16486  NiCca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue vertical line at center of grid
16487  k = 0
16488  while (k < 10):
16489  l = 1
16490  while (l < 5): # add tick marks
16491  Dline = [x-5,y1+k*mg_siz+l*mg_inc,x+5,y1+k*mg_siz+l*mg_inc]
16492  NiCca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
16493  l = l + 1
16494  k = k + 1
16495  else:
16496  NiCca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
16497  NiCca.create_text(x, y2+3, text=axis_label, fill=COLORtrace3, anchor="n", font=("arial", FontSize ))
16498  i = i + 1
16499  # Draw traces
16500  # Vertical conversion factors (level dBs) and border limits
16501  Yconv = float(GRHNiC) / (Vdiv.get() * DBdivlist[DBdivindexBP.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
16502  Yc = float(Y0TNiC) + Yconv * (DBlevelBP.get()) # Yc is the 0 dBm position, can be outside the screen!
16503  Xphconv = float(GRWNiC / 360.0) # degrees per pixel
16504  Xp = float(X0LNiC) + Xphconv * 180.0
16505  x1 = X0LNiC + 14
16506  # Horizontal conversion factors (phase deg) and border limits
16507  NiCline = []
16508  if len(FSweepAdB) > 4:
16509  index = 0
16510  for index in range(len(FSweepAdB)): # while n < len(FStep):
16511  if index < len(FStep): # check if n has gone out off bounds because user did something dumb
16512  F = FBins[int(FStep[index])] # look up frequency bin in list of bins
16513  else:
16514  F = FBins[int(FStep[0])]
16515  # Mag value
16516  dbA = 10 * math.log10(float(FSweepAdB[index])) # Convert power to DBs, except for log(0) error
16517  dbB = 10 * math.log10(float(FSweepBdB[index]))
16518  if ShowMathBP.get() == 1:
16519  MdB = dbA - dbB
16520  elif ShowMathBP.get() == 2:
16521  MdB = dbB - dbA
16522  yb = Yc - Yconv * MdB
16523  if (yb < Ymin):
16524  yb = Ymin
16525  if (yb > Ymax):
16526  yb = Ymax
16527  # Phase Value
16528  RelPhase = FSweepBPh[index] - FSweepAPh[index]
16529  RelPhase = RelPhase - Phasecenter
16530  if RelPhase > 180:
16531  RelPhase = RelPhase - 360
16532  elif RelPhase < -180:
16533  RelPhase = RelPhase + 360
16534  if Two_X_Sample.get() == 0:
16535  PhErr = 0.0018 * F # calculate phase error due half sample period offset
16536  RelPhase = RelPhase - PhErr # - PhaseOffset1x # - 12.0
16537  else:
16538  RelPhase = RelPhase # - PhaseOffset2x
16539  xa = Xp + Xphconv * RelPhase
16540  if (xa < Xmin):
16541  xa = Ymin
16542  if (xa > Xmax):
16543  xa = Xmax
16544  NiCline.append(int(xa + 0.5))
16545  NiCline.append(int(yb + 0.5))
16546  NiCca.create_line(NiCline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
16547 #
16548 def UpdateNqPAll(): # Update Data, trace and screen
16549  global FFTBuffA, FFTBuffB
16550  global SMPfft
16551 
16552  if len(FFTBuffA) < SMPfft and len(FFTBuffB) < SMPfft:
16553  return
16554  #MakeNqPTrace() # Update the traces
16555  UpdateNqPScreen() # Update the screen
16556 
16557 def UpdateNqPTrace(): # Update trace and screen
16558 
16559  #MakeNqPTrace() # Update traces
16560  UpdateNqPScreen() # Update the screen
16561 
16562 def UpdateNqPScreen(): # Update screen with trace and text
16563 
16564  MakeNqPScreen() # Update the screen
16565  root.update() # Activate updated screens
16566 #
16567 def UpdateNiCAll(): # Update Data, trace and screen
16568  global FFTBuffA, FFTBuffB
16569  global SMPfft
16570 
16571  if len(FFTBuffA) < SMPfft and len(FFTBuffB) < SMPfft:
16572  return
16573  #MakeNiCTrace() # Update the traces
16574  UpdateNiCScreen() # Update the screen
16575 
16576 def UpdateNiCTrace(): # Update trace and screen
16577 
16578  #MakeNiCTrace() # Update traces
16579  UpdateNiCScreen() # Update the screen
16580 
16581 def UpdateNiCScreen(): # Update screen with trace and text
16582 
16583  MakeNiCScreen() # Update the screen
16584  root.update() # Activate updated screens
16585 #
16586 #
16587 def VAtoggle():
16588  global vat_btn
16589 
16590  if vat_btn.config('text')[-1] == 'ON':
16591  vat_btn.config(text='OFF', style="Stop.TButton")
16592  else:
16593  vat_btn.config(text='ON', style="Run.TButton")
16594 #
16595 def VABtoggle():
16596  global vabt_btn
16597 
16598  if vabt_btn.config('text')[-1] == 'ON':
16599  vabt_btn.config(text='OFF', style="Stop.TButton")
16600  else:
16601  vabt_btn.config(text='ON', style="Run.TButton")
16602 #
16603 def VBtoggle():
16604  global vbt_btn
16605 
16606  if vbt_btn.config('text')[-1] == 'ON':
16607  vbt_btn.config(text='OFF', style="Stop.TButton")
16608  else:
16609  vbt_btn.config(text='ON', style="Run.TButton")
16610 #
16611 def IAtoggle():
16612  global iat_btn
16613 
16614  if iat_btn.config('text')[-1] == 'ON':
16615  iat_btn.config(text='OFF', style="Stop.TButton")
16616  else:
16617  iat_btn.config(text='ON', style="Run.TButton")
16618 #
16619 def IBtoggle():
16620  global ibt_btn
16621 
16622  if ibt_btn.config('text')[-1] == 'ON':
16623  ibt_btn.config(text='OFF', style="Stop.TButton")
16624  else:
16625  ibt_btn.config(text='ON', style="Run.TButton")
16626 #
16628  global iapbt_btn
16629 
16630  if iapbt_btn.config('text')[-1] == 'ON':
16631  iapbt_btn.config(text='OFF', style="Stop.TButton")
16632  else:
16633  iapbt_btn.config(text='ON', style="Run.TButton")
16634 #
16635 # ================ Make Phase Ana Window ==========================
16636 def MakePhAWindow():
16637  global phawindow, PhAca, logo, PhAScreenStatus, PhADisp, AWGSync
16638  global COLORcanvas, CANVASwidthPhA, CANVASheightPhA, RevDate, AWGAMode, AWGAShape, AWGBMode
16639  global FFTwindow, CutDC, ColorMode, RefPhase, CHvpdiv, CHipdiv
16640  global GRWPhA, X0LPhA, GRHPhA, Y0TPhA, DeBugMode, SWRev, PhAPlotMode
16641  global VScale, IScale, RefphEntry, MuxScreenStatus, AppendPhAData
16642  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn, iapbt_btn
16643  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D
16644  global FrameRefief, BorderSize
16645 
16646  if PhAScreenStatus.get() == 0:
16647  PhAScreenStatus.set(1)
16648  PhADisp.set(1)
16649  PhACheckBox()
16650  CutDC.set(1) # set to remove DC
16651  CANVASwidthPhA = GRWPhA + 2 * X0LPhA + int(21.25 * FontSize) # The canvas width
16652  CANVASheightPhA = GRHPhA + Y0TPhA + int(2.25 * FontSize) # The canvas height
16653  phawindow = Toplevel()
16654  phawindow.title("Phase Analyzer " + SWRev + RevDate)
16655  phawindow.protocol("WM_DELETE_WINDOW", DestroyPhAScreen)
16656  frame2phar = Frame(phawindow, borderwidth=BorderSize, relief=FrameRefief)
16657  frame2phar.pack(side=RIGHT, expand=NO, fill=BOTH)
16658 
16659  frame2pha = Frame(phawindow, borderwidth=BorderSize, relief=FrameRefief)
16660  frame2pha.pack(side=TOP, expand=YES, fill=BOTH)
16661 
16662  PhAca = Canvas(frame2pha, width=CANVASwidthPhA, height=CANVASheightPhA, background=COLORcanvas, cursor='cross')
16663  PhAca.bind("<Configure>", PhACaresize)
16664  PhAca.bind("<Return>", DoNothing)
16665  PhAca.bind("<space>", onCanvasSpaceBar)
16666  PhAca.pack(side=TOP, expand=YES, fill=BOTH)
16667 
16668  if MuxScreenStatus.get() == 0:
16669  RefPhase = ("CA-V", "CB-V", "CA-I", "CB-I")
16670  else:
16671  RefPhase = ("CA-V", "CB-A", "CB-B", "CB-C", "CB-D","CA-I", "CB-I")
16672  # menu buttons
16673  # right side drop down menu buttons
16674  dropmenu = Frame( frame2phar )
16675  dropmenu.pack(side=TOP)
16676  # File menu
16677  PhAFilemenu = Menubutton(dropmenu, text="File", style="W5.TButton")
16678  PhAFilemenu.menu = Menu(PhAFilemenu, tearoff = 0 )
16679  PhAFilemenu["menu"] = PhAFilemenu.menu
16680  PhAFilemenu.menu.add_command(label="Save Config", command=BSaveConfigIA)
16681  PhAFilemenu.menu.add_command(label="Load Config", command=BLoadConfigIA)
16682  PhAFilemenu.menu.add_command(label="Run Script", command=RunScript)
16683  PhAFilemenu.menu.add_command(label="Save Data", command=BSavePhAData)
16684  PhAFilemenu.menu.add_checkbutton(label=' - Append', variable=AppendPhAData)
16685  PhAFilemenu.menu.add_command(label="Plot From File", command=PlotPhAFromFile)
16686  PhAFilemenu.menu.add_radiobutton(label=' - Vectors', variable=PhAPlotMode, value=0)
16687  PhAFilemenu.menu.add_radiobutton(label=' - Outline', variable=PhAPlotMode, value=1)
16688  PhAFilemenu.menu.add_command(label="Help", command=BHelp)
16689  PhAFilemenu.pack(side=LEFT, anchor=W)
16690  #
16691  PhAOptionmenu = Menubutton(dropmenu, text="Options", style="W8.TButton")
16692  PhAOptionmenu.menu = Menu(PhAOptionmenu, tearoff = 0 )
16693  PhAOptionmenu["menu"] = PhAOptionmenu.menu
16694  PhAOptionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
16695  PhAOptionmenu.menu.add_command(label='Set Sample Rate', command=MakeSampleRateMenu) # SetSampleRate)
16696  PhAOptionmenu.menu.add_checkbutton(label='Cut-DC', variable=CutDC)
16697 
16698  PhAOptionmenu.menu.add_command(label="-Background-", command=donothing)
16699  PhAOptionmenu.menu.add_radiobutton(label='Black', variable=ColorMode, value=0, command=BgColor)
16700  PhAOptionmenu.menu.add_radiobutton(label='White', variable=ColorMode, value=1, command=BgColor)
16701  PhAOptionmenu.pack(side=LEFT, anchor=W)
16702  #
16703  rsphmenu = Frame( frame2phar )
16704  rsphmenu.pack(side=TOP)
16705  rsphb2 = Button(rsphmenu, text="Stop", style="Stop.TButton", command=BStop)
16706  rsphb2.pack(side=RIGHT)
16707  rsphb3 = Button(rsphmenu, text="Run", style="Run.TButton", command=BStart)
16708  rsphb3.pack(side=RIGHT)
16709  #
16710  PhAFFTwindmenu = Menubutton(frame2phar, text="FFTwindow", style="W11.TButton")
16711  PhAFFTwindmenu.menu = Menu(PhAFFTwindmenu, tearoff = 0 )
16712  PhAFFTwindmenu["menu"] = PhAFFTwindmenu.menu
16713  PhAFFTwindmenu.menu.add_radiobutton(label='Rectangular window (B=1)', variable=FFTwindow, value=0)
16714  PhAFFTwindmenu.menu.add_radiobutton(label='Cosine window (B=1.24)', variable=FFTwindow, value=1)
16715  PhAFFTwindmenu.menu.add_radiobutton(label='Triangular window (B=1.33)', variable=FFTwindow, value=2)
16716  PhAFFTwindmenu.menu.add_radiobutton(label='Hann window (B=1.5)', variable=FFTwindow, value=3)
16717  PhAFFTwindmenu.menu.add_radiobutton(label='Blackman window (B=1.73)', variable=FFTwindow, value=4)
16718  PhAFFTwindmenu.menu.add_radiobutton(label='Nuttall window (B=2.02)', variable=FFTwindow, value=5)
16719  PhAFFTwindmenu.menu.add_radiobutton(label='Flat top window (B=3.77)', variable=FFTwindow, value=6)
16720  PhAFFTwindmenu.pack(side=TOP)
16721  #
16722  FFTwindow.set(6) # default to Flat top window (6)
16723  #
16724  smphmenu = Frame( frame2phar )
16725  smphmenu.pack(side=TOP)
16726  smphb1 = Button(smphmenu, text="-Samples", style="W8.TButton", command=Bsamples1)
16727  smphb1.pack(side=LEFT)
16728  smphb2 = Button(smphmenu, text="+Samples", style="W8.TButton", command=Bsamples2)
16729  smphb2.pack(side=LEFT)
16730  #
16731  refph = Frame( frame2phar )
16732  refph.pack(side=TOP)
16733  refphlab = Label(refph, text="Ref Phase")
16734  refphlab.pack(side=LEFT, anchor=W)
16735  RefphEntry = Spinbox(refph, width=5, cursor='double_arrow', values=RefPhase)
16736  RefphEntry.bind('<MouseWheel>', onSpinBoxScroll)
16737  RefphEntry.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
16738  RefphEntry.bind("<Button-5>", onSpinBoxScroll)
16739  RefphEntry.pack(side=LEFT, anchor=W)
16740  RefphEntry.delete(0,"end")
16741  RefphEntry.insert(0,"CA-V")
16742  vatb = Frame( frame2phar )
16743  vatb.pack(side=TOP)
16744  vatblab = Label(vatb, text="CA-V ")
16745  vatblab.pack(side=LEFT)
16746  vat_btn = Button(vatb, text="OFF", style="Stop.TButton", width=4, command=VAtoggle)
16747  vat_btn.pack(side=LEFT)
16748  vbtb = Frame( frame2phar )
16749  vbtb.pack(side=TOP)
16750  if MuxScreenStatus.get() == 0:
16751  #RefPhase = ("CA-V", "CB-V", "CA-I", "CB-I")
16752  vbtblab = Label(vbtb, text="CB-V ")
16753  vbtblab.pack(side=LEFT)
16754  vbt_btn = Button(vbtb, text="OFF", style="Stop.TButton", width=4, command=VBtoggle)
16755  vbt_btn.pack(side=LEFT)
16756  vabtb = Frame( frame2phar )
16757  vabtb.pack(side=TOP)
16758  vabtblab = Label(vabtb, text="CA-B V ")
16759  vabtblab.pack(side=LEFT)
16760  vabt_btn = Button(vabtb, text="OFF", style="Stop.TButton", width=4, command=VABtoggle)
16761  vabt_btn.pack(side=LEFT)
16762  else:
16763  #RefphEntry.configure(state=DISABLED)
16764  #RefPhase = ("CA-V", "CB-A", "CB-B", "CB-C", "CB-D","CA-I", "CB-I")
16765  amuxlab = Label(frame2phar, text="Analog Mux In")
16766  amuxlab.pack(side=TOP)
16767  phbt1 = Checkbutton(frame2phar, text='CB-A ', style="Strace2.TCheckbutton", variable=ShowPB_A)
16768  phbt1.pack(side=TOP)
16769  phbt2 = Checkbutton(frame2phar, text='CB-B ', style="Strace6.TCheckbutton", variable=ShowPB_B) #, command=TraceSelectADC_Mux)
16770  phbt2.pack(side=TOP)
16771  phbt3 = Checkbutton(frame2phar, text='CB-C ', style="Strace7.TCheckbutton", variable=ShowPB_C) #, command=TraceSelectADC_Mux)
16772  phbt3.pack(side=TOP)
16773  phbt4 = Checkbutton(frame2phar, text='CB-D ', style="Strace4.TCheckbutton", variable=ShowPB_D) #, command=TraceSelectADC_Mux)
16774  phbt4.pack(side=TOP)
16775 #
16776  # Voltage Scale Spinbox
16777  vssb = Frame( frame2phar )
16778  vssb.pack(side=TOP)
16779  vslab = Label(vssb, text="Volts/div ")
16780  vslab.pack(side=LEFT)
16781  VScale = Spinbox(vssb, width=7, cursor='double_arrow', values=CHvpdiv)
16782  VScale.bind('<MouseWheel>', onSpinBoxScroll)
16783  VScale.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
16784  VScale.bind("<Button-5>", onSpinBoxScroll)
16785  VScale.pack(side=LEFT)
16786  VScale.delete(0,"end")
16787  VScale.insert(0,0.5)
16788  #
16789  iatb = Frame( frame2phar )
16790  iatb.pack(side=TOP)
16791  iatblab = Label(iatb, text="CA-I ")
16792  iatblab.pack(side=LEFT)
16793  iat_btn = Button(iatb, text="OFF", style="Stop.TButton", width=4, command=IAtoggle)
16794  iat_btn.pack(side=LEFT)
16795  ibtb = Frame( frame2phar )
16796  ibtb.pack(side=TOP)
16797  ibtblab = Label(ibtb, text="CB-I ")
16798  ibtblab.pack(side=LEFT)
16799  ibt_btn = Button(ibtb, text="OFF", style="Stop.TButton", width=4, command=IBtoggle)
16800  ibt_btn.pack(side=LEFT)
16801  iabtb = Frame( frame2phar )
16802  iabtb.pack(side=TOP)
16803  iapbbtblab = Label(iabtb, text="CA+B I ")
16804  iapbbtblab.pack(side=LEFT)
16805  iapbt_btn = Button(iabtb, text="OFF", style="Stop.TButton", width=4, command=IApBtoggle)
16806  iapbt_btn.pack(side=LEFT)
16807  # Current Scale Spinbox
16808  issb = Frame( frame2phar )
16809  issb.pack(side=TOP)
16810  islab = Label(issb, text="mA/div ")
16811  islab.pack(side=LEFT)
16812  IScale = Spinbox(issb, width=7, cursor='double_arrow', values=CHipdiv)
16813  IScale.bind('<MouseWheel>', onSpinBoxScroll)
16814  IScale.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
16815  IScale.bind("<Button-5>", onSpinBoxScroll)
16816  IScale.pack(side=LEFT)
16817  IScale.delete(0,"end")
16818  IScale.insert(0,10.0)
16819 
16820  dismiss1button = Button(frame2phar, text="Dismiss", style="W8.TButton", command=DestroyPhAScreen)
16821  dismiss1button.pack(side=TOP)
16822  # add ADI logo
16823  ADI1 = Label(frame2phar, image=logo, anchor= "sw", compound="top") # height=49, width=116,
16824  ADI1.pack(side=TOP)
16825 #
16826 # Destroy Phase Analizer window
16827 def DestroyPhAScreen():
16828  global phawindow, PhAScreenStatus, PhAca, PhADisp
16829 
16830  PhAScreenStatus.set(0)
16831  PhADisp.set(0)
16832  PhACheckBox()
16833  phawindow.destroy()
16834 #
16835 # Resize Phase Analizer window
16836 def PhACaresize(event):
16837  global PhAca, GRWPhA, XOLPhA, GRHPhA, Y0TPhA, CANVASwidthPhA, CANVASheightPhA, FontSize
16838 
16839  CANVASwidthPhA = event.width - 4
16840  CANVASheightPhA = event.height - 4
16841  GRWPhA = CANVASwidthPhA - (2 * X0LPhA) - int(21.25 * FontSize) # 170 new grid width
16842  GRHPhA = CANVASheightPhA - Y0TPhA - int(2.25 * FontSize) # 10 new grid height
16843  UpdatePhAAll()
16844 #
16845 def UpdatePhAAll(): # Update Data, trace and screen
16846 
16847  MakePhATrace() # Update the traces
16848  UpdatePhAScreen() # Update the screen
16849 
16850 def UpdatePhATrace(): # Update trace and screen
16851  MakePhATrace() # Update traces
16852  UpdatePhAScreen() # Update the screen
16853 
16854 def UpdatePhAScreen(): # Update screen with trace and text
16855  MakePhAScreen() # Update the screen
16856  root.update() # Activate updated screens
16857 #
16858 # Place holder
16859 def MakePhATrace(): # Update the grid and trace
16860  global VAresult, VBresult, IAresult, IBresult, VABresult, IABresult, PhaseIA, PhaseIB, PhaseVA, PhaseVB, PhaseVAB, PhaseIAB
16861  global VMAresult, VMBresult, VMCresult, VMDresult, PhaseVMD, PhaseVMA, PhaseVMB, PhaseVMC
16862  global PeakVA, PeakVB, PeakIA, PeakIB, PeakVAB, PeakIAB
16863  global PeakVMA, PeakVMB, PeakVMC, PeakVMD
16864  global PeakfreqVA, PeakfreqVB, PeakfreqIA, PeakfreqIB
16865  global PeakphaseVA, PeakphaseVB, PeakphaseIA, PeakphaseIB, PeakphaseVAB, PeakphaseIAB
16866  global PeakphaseVMA, PeakphaseVMB, PeakphaseVMC, PeakphaseVMD
16867  global PeakfreqVMA, PeakfreqVMB, PeakfreqVMC, PeakfreqVMD
16868  global GRHPhA # Screenheight
16869  global GRWPhA # Screenwidth
16870  global AWGSAMPLErate, SAMPLErate, BaseSampleRate
16871  global STARTsample, STOPsample, LoopNum, FSweepMode
16872  global TRACEmode, Two_X_Sample, MuxScreenStatus, MuxChan, ChopMuxMode
16873  global Vdiv # Number of vertical divisions
16874  global X0LPhA # Left top X value
16875  global Y0TPhA # Left top Y value
16876 
16877  # Set the TRACEsize variable
16878  if len(VAresult) < 32:
16879  return
16880  TRACEsize = len(VAresult) # Set the trace length
16881  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1)
16882  # Horizontal conversion factors (frequency Hz) and border limits
16883  STARTsample = 0 # First sample in FFTresult[] that is used
16884  STARTsample = int(math.ceil(STARTsample)) # First within screen range
16885  if Two_X_Sample.get() == 0:
16886  STOPsample = 45000 / Fsample # Last sample in FFTresult that is used
16887  else:
16888  STOPsample = 90000 / Fsample
16889  STOPsample = int(math.floor(STOPsample)) # Last within screen range, math.floor actually not necessary, part of int
16890 #
16891 
16892  MAXsample = TRACEsize # Just an out of range check
16893  if STARTsample > (MAXsample - 1):
16894  STARTsample = MAXsample - 1
16895 
16896  if STOPsample > MAXsample:
16897  STOPsample = MAXsample
16898 
16899  n = STARTsample +1
16900  PeakVA = PeakVB = PeakIA = PeakIB = PeakVAB = PeakIAB = 0.0
16901  PeakfreqVA = PeakfreqVB = PeakfreqIA = PeakfreqIB = PeakfreqIAB = F = n * Fsample
16902  PeakphaseVA = PhaseVA[n]
16903  if MuxScreenStatus.get() == 0:
16904  PeakphaseVB = PhaseVB[n]
16905  else:
16906  PeakphaseVMA = PeakphaseVMB = PeakphaseVMC = PeakphaseVMD = 0.0
16907  PeakphaseIA = PhaseIA[n]
16908  PeakphaseIB = PhaseIB[n]
16909  PeakphaseIAB = PhaseIAB[n]
16910  PeakSampleVB = PeakSampleVA = PeakSampleIA = PeakSampleIB = n
16911  PeakSampleVMA = PeakSampleVMB = PeakSampleVMC = PeakSampleVMD = n
16912  if MuxChan == 0 or ChopMuxMode.get() > 0: #
16913  PeakVMA = 0
16914  PeakphaseVMA = PhaseVMA[n]
16915  PeakSampleVMA = 0
16916  PeakfreqVMA = PeakfreqVA
16917  if MuxChan == 1 or ChopMuxMode.get() > 0: #
16918  PeakVMB = 0
16919  PeakphaseVMB = PhaseVMB[n]
16920  PeakSampleVMB = 0
16921  PeakfreqVMB = PeakfreqVA
16922  if MuxChan == 2 or ChopMuxMode.get() > 0: #
16923  PeakVMC = 0
16924  PeakphaseVMC = PhaseVMC[n]
16925  PeakSampleVMC = 0
16926  PeakfreqVMC = PeakfreqVA
16927  if MuxChan == 3 or ChopMuxMode.get() > 0: #
16928  PeakVMD = 0
16929  PeakphaseVMD = PhaseVMD[n]
16930  PeakSampleVMD = 0
16931  PeakfreqVMD = PeakfreqVA
16932 
16933  while n <= STOPsample: # search for peaks
16934  F = n * Fsample
16935  try:
16936  VA = float(VAresult[n]) #
16937  except:
16938  VA = 0.0
16939  if VA > PeakVA:
16940  PeakVA = VA
16941  PeakfreqVA = F
16942  PeakphaseVA = PhaseVA[n]
16943  PeakSampleVA = n
16944 
16945  if MuxScreenStatus.get() == 0:
16946  try:
16947  VAB = float(VABresult[n]) #
16948  except:
16949  VAB = 0.0
16950  if VAB > PeakVAB:
16951  PeakVAB = VAB
16952  PeakfreqVAB = F
16953  PeakphaseVAB = PhaseVAB[n]
16954  PeakSampleVAB = n
16955 
16956  try:
16957  VB = float(VBresult[n]) #
16958  except:
16959  VB = 0.0
16960  if VB > PeakVB:
16961  PeakVB = VB
16962  PeakfreqVB = F
16963  PeakphaseVB = PhaseVB[n]
16964  PeakSampleVB = n
16965  else:
16966  if MuxChan == 0 or ChopMuxMode.get() > 0: #
16967  try:
16968  VMA = float(VMAresult[n]) #
16969  except:
16970  VMA = 0.0
16971  if VMA > PeakVMA:
16972  PeakVMA = VMA
16973  PeakfreqVMA = F
16974  PeakphaseVMA = PhaseVMA[n]
16975  PeakSampleVMA = n
16976  if MuxChan == 1 or ChopMuxMode.get() > 0: #
16977  try:
16978  VMB = float(VMBresult[n]) #
16979  except:
16980  VMB = 0.0
16981  if VMB > PeakVMB:
16982  PeakVMB = VMB
16983  PeakfreqVMB = F
16984  PeakphaseVMB = PhaseVMB[n]
16985  PeakSampleVMB = n
16986  if MuxChan == 2 or ChopMuxMode.get() > 0: #
16987  try:
16988  VMC = float(VMCresult[n]) #
16989  except:
16990  VMC = 0.0
16991  if VMC > PeakVMC:
16992  PeakVMC = VMC
16993  PeakfreqVMC = F
16994  PeakphaseVMC = PhaseVMC[n]
16995  PeakSampleVMC = n
16996  if MuxChan == 3 or ChopMuxMode.get() > 0: #
16997  try:
16998  VMD = float(VMDresult[n]) #
16999  except:
17000  VMD = 0.0
17001  if VMD > PeakVMD:
17002  PeakVMD = VMD
17003  PeakfreqVMD = F
17004  PeakphaseVMD = PhaseVMD[n]
17005  PeakSampleVMD = n
17006  try:
17007  IA = float(IAresult[n]) #
17008  except:
17009  IA = 0.0
17010  if IA > PeakIA:
17011  PeakIA = IA
17012  PeakfreqIA = F
17013  PeakphaseIA = PhaseIA[n]
17014  PeakSampleIA = n
17015 
17016  try:
17017  IB = float(IBresult[n]) #
17018  except:
17019  IB = 0.0
17020  if IB > PeakIB:
17021  PeakIB = IB
17022  PeakfreqIB = F
17023  PeakphaseIB = PhaseIB[n]
17024  PeakSampleIB = n
17025 
17026  try:
17027  IAB = float(IABresult[n]) #
17028  except:
17029  IAB = 0.0
17030  if IAB > PeakIAB:
17031  PeakIAB = IAB
17032  PeakfreqIAB = F
17033  PeakphaseIAB = PhaseIAB[n]
17034  PeakSampleIAB = n
17035 
17036  n = n + 1
17037 
17038  # Check to see that V, Vnux and I peaks are in same frequency bin?
17039  if PeakSampleVA != PeakSampleIA:
17040  PeakphaseIA = PhaseIA[PeakSampleVA]
17041  PeakIA = IAresult[PeakSampleVA]
17042  if PeakSampleVB != PeakSampleIB and MuxScreenStatus.get() == 0:
17043  PeakphaseIB = PhaseIB[PeakSampleVB]
17044  PeakIB = IBresult[PeakSampleVB]
17045  if MuxScreenStatus.get() > 0:
17046  if PeakSampleVA != PeakSampleVMA:
17047  try:
17048  PeakphaseVMA = PhaseVMA[PeakSampleVA]
17049  PeakVMA = float(VMAresult[PeakSampleVA])
17050  except:
17051  donothing()
17052  if PeakSampleVA != PeakSampleVMB:
17053  try:
17054  PeakphaseVMB = PhaseVMB[PeakSampleVA]
17055  PeakVMB = float(VMBresult[PeakSampleVA])
17056  except:
17057  donothing()
17058  if PeakSampleVA != PeakSampleVMC:
17059  try:
17060  PeakphaseVMC = PhaseVMC[PeakSampleVA]
17061  PeakVMC = float(VMCresult[PeakSampleVA])
17062  except:
17063  donothing()
17064  if PeakSampleVA != PeakSampleVMD:
17065  try:
17066  PeakphaseVMD = PhaseVMD[PeakSampleVA]
17067  PeakVMD = float(VMDresult[PeakSampleVA])
17068  except:
17069  donothing()
17070 #
17071 # Draw the Phase Analyzer screen
17072 def MakePhAScreen(): # Update the screen with traces and text
17073  global PeakVA, PeakVB, PeakIA, PeakIB, PeakVAB, PeakIAB
17074  global PeakfreqVA, PeakfreqVB, PeakfreqIA, PeakfreqIB
17075  global PeakphaseVA, PeakphaseVB, PeakphaseIA, PeakphaseIB, PeakphaseVAB, PeakphaseIAB
17076  global PeakVMA, PeakVMB, PeakVMC, PeakVMD
17077  global PeakphaseVMA, PeakphaseVMB, PeakphaseVMC, PeakphaseVMD
17078  global PeakfreqVMA, PeakfreqVMB, PeakfreqVMC, PeakfreqVMD
17079  global CAVphase, CBVphase, CAIphase, CBIphase, CABVphase
17080  global CMAphase, CMBphase, CMCphase, CMDphase
17081  global CANVASheightPhA, CANVASwidthPhA, PhAca, TRACEwidth, GridWidth
17082  global COLORsignalband, COLORtext, COLORgrid # The colors
17083  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5, COLORtrace6, COLORtrace7
17084  global FFTwindow, FFTbandwidth, ZEROstuffing, FFTwindowname
17085  global X0LPhA # Left top X value
17086  global Y0TPhA # Left top Y value
17087  global GRWPhA # Screenwidth
17088  global GRHPhA # Screenheight
17089  global FontSize, MuxScreenStatus, MuxChan, Mulx, ChopMuxMode
17090  global RUNstatus # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
17091  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, OverRangeFlagA, OverRangeFlagB
17092  global SMPfft # number of FFT samples
17093  global TRACEaverage # Number of traces for averageing
17094  global FreqTraceMode # 1 normal 2 max 3 average
17095  global Vdiv, VScale, IScale # Number of vertical divisions
17096  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn, iapbt_btn
17097  global AWGBMode, AWGBIOMode, ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D
17098  global ShowC1_V, ShowC2_V, ShowC1_I, ShowC2_I, CHA_RC_HP, CHB_RC_HP
17099  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2, CHAHW, CHALW, CHADCy, CHAperiod, CHAfreq
17100  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2, CHBHW, CHBLW, CHBDCy, CHBperiod, CHBfreq
17101  global InOffA, InGainA, InOffB, InGainB
17102  global CurOffA, CurOffB, CurGainA, CurGainB
17103  # Analog Mux channel measurement variables
17104  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
17105  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
17106  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
17107  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
17108  global SV1, SI1, SV2, SI2, CHABphase, SVA_B
17109  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1
17110  global MeasDCI1, MeasMinI1, MeasMaxI1, MeasMidI1, MeasPPI1
17111  global MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2, MeasPPV2
17112  global MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2
17113  global MeasRMSV1, MeasRMSI1, MeasRMSV2, MeasRMSI2, MeasPhase, MeasRMSVA_B
17114  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ
17115  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
17116 
17117  # Delete all items on the screen
17118  PhAca.delete(ALL) # remove all items
17119  # SmoothBool = SmoothCurvesBP.get()
17120  # Draw circular grid lines
17121  i = 1
17122  xcenter = GRWPhA/2
17123  ycenter = (GRHPhA/2) + 14
17124  Radius = (GRWPhA-X0LPhA)/(1 + Vdiv.get()*2) # 11
17125  VoltsperPixel = float(VScale.get())/Radius
17126  mAperPixel = float(IScale.get())/Radius
17127  TRadius = Radius * Vdiv.get() # 5
17128  x1 = X0LPhA
17129  x2 = X0LPhA + GRWPhA
17130  xright = 10 + xcenter + ( Vdiv.get() * Radius ) # 5
17131  while (i <= Vdiv.get()):
17132  x0 = xcenter - ( i * Radius )
17133  x1 = xcenter + ( i * Radius )
17134  y0 = ycenter - ( i * Radius )
17135  y1 = ycenter + ( i * Radius )
17136  VTxt = '{0:.2f}'.format(float(VScale.get()) * i)
17137  ITxt = '{0:.2f}'.format(float(IScale.get()) * i)
17138  TOffset = xright+(4*FontSize)
17139  PhAca.create_oval( x0, y0, x1, y1, outline=COLORgrid, width=GridWidth.get())
17140  PhAca.create_line(xcenter, y0, xright, y0, fill=COLORgrid, width=GridWidth.get(), dash=(4,3))
17141  PhAca.create_text(xright, y0, text=str(VTxt), fill=COLORtrace1, anchor="w", font=("arial", FontSize+2 ))
17142  if iat_btn.config('text')[-1] == 'ON' or ibt_btn.config('text')[-1] == 'ON':
17143  PhAca.create_text(TOffset, y0, text=str(ITxt), fill=COLORtrace3, anchor="w", font=("arial", FontSize+2 ))
17144  #
17145  i = i + 1
17146  PhAca.create_line(xcenter, y0, xcenter, y1, fill=COLORgrid, width=GridWidth.get())
17147  PhAca.create_line(x0, ycenter, x1, ycenter, fill=COLORgrid, width=GridWidth.get())
17148  RAngle = math.radians(45)
17149  y = TRadius*math.sin(RAngle)
17150  x = TRadius*math.cos(RAngle)
17151  PhAca.create_line(xcenter-x, ycenter-y, xcenter+x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
17152  PhAca.create_line(xcenter+x, ycenter-y, xcenter-x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
17153  PhAca.create_text(x0, ycenter, text="180", fill=COLORgrid, anchor="e", font=("arial", FontSize+2 ))
17154  PhAca.create_text(x1, ycenter, text="0.0", fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
17155  PhAca.create_text(xcenter, y0, text="90", fill=COLORgrid, anchor="s", font=("arial", FontSize+2 ))
17156  PhAca.create_text(xcenter, y1, text="-90", fill=COLORgrid, anchor="n", font=("arial", FontSize+2 ))
17157  YBot = y1
17158  # calculate phase error due half sample period offset 0.0018
17159  if Two_X_Sample.get() == 0:
17160  if AWGBMode.get() == 2 or AWGBIOMode.get() > 0:
17161  PhErr = 0.001675 * PeakfreqVA
17162  PhErrMA = PhErr
17163  PhErrMB = PhErr
17164  PhErrMC = PhErr
17165  PhErrMD = PhErr
17166  else:
17167  PhErr = 0.0
17168  PhErrMA = PhErr
17169  PhErrMB = PhErr
17170  PhErrMC = PhErr
17171  PhErrMD = PhErr
17172  else:
17173  PhErr = 0.0
17174  PhErrMA = PhErr
17175  PhErrMB = PhErr
17176  PhErrMC = PhErr
17177  PhErrMD = PhErr
17178  if ChopMuxMode.get() > 0:
17179  PhErrMB = 0.0072 * PeakfreqVMB
17180  PhErrMA = 0.0016 * PeakfreqVMA #
17181  PhErrMD = 0.0054 * PeakfreqVMD
17182  PhErrMC = 0.0016 * PeakfreqVMC #
17183 # Draw traces
17184 #
17185  if RefphEntry.get() == "CA-V":
17186  CAVphase = 0.0
17187  CBVphase = PeakphaseVA - PeakphaseVB + PhErr
17188  CAIphase = PeakphaseVA - PeakphaseIA
17189  CBIphase = PeakphaseVA - PeakphaseIB + PhErr
17190  CABVphase = PeakphaseVA - PeakphaseVAB
17191  CABIphase = PeakphaseVA - PeakphaseIAB
17192  elif RefphEntry.get() == "CB-V":
17193  CBVphase = 0.0
17194  CAVphase = PeakphaseVB - PeakphaseVA - PhErr
17195  CAIphase = PeakphaseVB - PeakphaseIA - PhErr
17196  CBIphase = PeakphaseVB - PeakphaseIB
17197  CABVphase = PeakphaseVB - PeakphaseVAB
17198  CABIphase = PeakphaseVB - PeakphaseIAB
17199  elif RefphEntry.get() == "CA-I":
17200  CAIphase = 0.0
17201  CAVphase = PeakphaseIA - PeakphaseVA
17202  CBVphase = PeakphaseIA - PeakphaseVB + PhErr
17203  CBIphase = PeakphaseIA - PeakphaseIB + PhErr
17204  CABVphase = PeakphaseIA - PeakphaseVAB
17205  CABIphase = PeakphaseIA - PeakphaseIAB
17206  elif RefphEntry.get() == "CB-I":
17207  CBIphase = 0.0
17208  CAVphase = PeakphaseIB - PeakphaseVA - PhErr
17209  CBVphase = PeakphaseIB - PeakphaseVB
17210  CAIphase = PeakphaseIB - PeakphaseIA - PhErr
17211  CABVphase = PeakphaseIB - PeakphaseVAB
17212  CABIphase = PeakphaseIB - PeakphaseIAB
17213  #
17214  if MuxScreenStatus.get() > 0:
17215  CBVphase = 0.0
17216  if RefphEntry.get() == "CA-V":
17217  CAVphase = 0.0
17218  CMAphase = PeakphaseVA - PeakphaseVMA + PhErr
17219  CMBphase = PeakphaseVA - PeakphaseVMB + PhErr
17220  CMCphase = PeakphaseVA - PeakphaseVMC + PhErr
17221  CMDphase = PeakphaseVA - PeakphaseVMD + PhErr
17222  CAIphase = PeakphaseVA - PeakphaseIA
17223  CBIphase = PeakphaseVA - PeakphaseIB + PhErr
17224  elif RefphEntry.get() == "CB-A":
17225  CMAphase = 0.0
17226  CAVphase = PeakphaseVMA - PeakphaseVA + PhErr
17227  CMBphase = PeakphaseVMA - PeakphaseVMB - PhErrMB
17228  CMCphase = PeakphaseVMA - PeakphaseVMC + PhErrMC
17229  CMDphase = PeakphaseVMA - PeakphaseVMD - PhErrMD
17230  CAIphase = PeakphaseVMA - PeakphaseIA
17231  CBIphase = PeakphaseVMA - PeakphaseIB + PhErr
17232  elif RefphEntry.get() == "CB-B":
17233  CMBphase = 0.0
17234  CAVphase = PeakphaseVMB - PeakphaseVA + PhErr
17235  CMAphase = PeakphaseVMB - PeakphaseVMA + PhErrMD
17236  CMCphase = PeakphaseVMB - PeakphaseVMC + PhErrMB
17237  CMDphase = PeakphaseVMB - PeakphaseVMD + PhErrMC
17238  CAIphase = PeakphaseVMB - PeakphaseIA
17239  CBIphase = PeakphaseVMB - PeakphaseIB + PhErr
17240  elif RefphEntry.get() == "CB-C":
17241  CMCphase = 0.0
17242  CAVphase = PeakphaseVMC - PeakphaseVA + PhErr
17243  CMAphase = PeakphaseVMC - PeakphaseVMA + PhErrMC
17244  CMBphase = PeakphaseVMC - PeakphaseVMB - PhErrMB
17245  CMDphase = PeakphaseVMC - PeakphaseVMD - PhErrMD
17246  CAIphase = PeakphaseVMC - PeakphaseIA
17247  CBIphase = PeakphaseVMC - PeakphaseIB + PhErr
17248  elif RefphEntry.get() == "CB-D":
17249  CMDphase = 0.0
17250  CAVphase = PeakphaseVMD - PeakphaseVA + PhErr
17251  CMAphase = PeakphaseVMD - PeakphaseVMA + PhErrMD
17252  CMBphase = PeakphaseVMD - PeakphaseVMB + PhErrMC
17253  CMCphase = PeakphaseVMD - PeakphaseVMC + PhErrMD
17254  CAIphase = PeakphaseVMD - PeakphaseIA
17255  CBIphase = PeakphaseVMD - PeakphaseIB + PhErr
17256 
17257  if CAVphase > 180:
17258  CAVphase = CAVphase - 360
17259  elif CAVphase < -180:
17260  CAVphase = CAVphase + 360
17261  if CBVphase > 180:
17262  CBVphase = CBVphase - 360
17263  elif CBVphase < -180:
17264  CBVphase = CBVphase + 360
17265  if CAIphase > 180:
17266  CAIphase = CAIphase - 360
17267  elif CAIphase < -180:
17268  CAIphase = CAIphase + 360
17269  if CBIphase > 180:
17270  CBIphase = CBIphase - 360
17271  elif CBIphase < -180:
17272  CBIphase = CBIphase + 360
17273  if CABVphase > 180:
17274  CABVphase = CABVphase - 360
17275  elif CABVphase < -180:
17276  CABVphase = CABVphase + 360
17277  if CABIphase > 180:
17278  CABIphase = CABIphase - 360
17279  elif CABIphase < -180:
17280  CABIphase = CABIphase + 360
17281  #
17282  if vat_btn.config('text')[-1] == 'ON':
17283  MagRadius = PeakVA / VoltsperPixel
17284  y1 = ycenter - MagRadius*math.sin(math.radians(CAVphase))
17285  if y1 > 1500:
17286  y1 = xright
17287  elif y1 < -500:
17288  y1 = ycenter - xright
17289  x1 = xcenter + MagRadius*math.cos(math.radians(CAVphase))
17290  if x1 > 1500:
17291  x1 = xright
17292  elif x1 < -500:
17293  x1 = xcenter - xright
17294  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace1, arrow="last", width=TRACEwidth.get())
17295  if MuxScreenStatus.get() == 0:
17296  if vbt_btn.config('text')[-1] == 'ON':
17297  MagRadius = PeakVB / VoltsperPixel
17298  y1 = ycenter - MagRadius*math.sin(math.radians(CBVphase))
17299  if y1 > 1500:
17300  y1 = xright
17301  elif y1 < -500:
17302  y1 = ycenter - xright
17303  x1 = xcenter + MagRadius*math.cos(math.radians(CBVphase))
17304  if x1 > 1500:
17305  x1 = xright
17306  elif x1 < -500:
17307  x1 = xcenter - xright
17308  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace2, arrow="last", width=TRACEwidth.get())
17309  else:
17310  if ShowPB_A.get() > 0:
17311  if CMAphase > 180:
17312  CMAphase = CMAphase - 360
17313  elif CMAphase < -180:
17314  CMAphase = CMAphase + 360
17315  MagRadius = PeakVMA / VoltsperPixel
17316  y1 = ycenter - MagRadius*math.sin(math.radians(CMAphase))
17317  if y1 > 1500:
17318  y1 = xright
17319  elif y1 < -500:
17320  y1 = ycenter - xright
17321  x1 = xcenter + MagRadius*math.cos(math.radians(CMAphase))
17322  if x1 > 1500:
17323  x1 = xright
17324  elif x1 < -500:
17325  x1 = xcenter - xright
17326  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace2, arrow="last", width=TRACEwidth.get())#
17327  if ShowPB_B.get() > 0:
17328  if CMBphase > 180:
17329  CMBphase = CMBphase - 360
17330  elif CMBphase < -180:
17331  CMBphase = CMBphase + 360
17332  MagRadius = PeakVMB / VoltsperPixel
17333  y1 = ycenter - MagRadius*math.sin(math.radians(CMBphase))
17334  if y1 > 1500:
17335  y1 = xright
17336  elif y1 < -500:
17337  y1 = ycenter - xright
17338  x1 = xcenter + MagRadius*math.cos(math.radians(CMBphase))
17339  if x1 > 1500:
17340  x1 = xright
17341  elif x1 < -500:
17342  x1 = xcenter - xright
17343  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace6, arrow="last", width=TRACEwidth.get())#
17344  if ShowPB_C.get() > 0:
17345  if CMCphase > 180:
17346  CMCphase = CMCphase - 360
17347  elif CMCphase < -180:
17348  CMCphase = CMCphase + 360
17349  MagRadius = PeakVMC / VoltsperPixel
17350  y1 = ycenter - MagRadius*math.sin(math.radians(CMCphase))
17351  if y1 > 1500:
17352  y1 = xright
17353  elif y1 < -500:
17354  y1 = ycenter - xright
17355  x1 = xcenter + MagRadius*math.cos(math.radians(CMCphase))
17356  if x1 > 1500:
17357  x1 = xright
17358  elif x1 < -500:
17359  x1 = xcenter - xright
17360  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace7, arrow="last", width=TRACEwidth.get())#
17361  if ShowPB_D.get() > 0:
17362  if CMDphase > 180:
17363  CMDphase = CMDphase - 360
17364  elif CMDphase < -180:
17365  CMDphase = CMDphase + 360
17366  MagRadius = PeakVMD / VoltsperPixel
17367  y1 = ycenter - MagRadius*math.sin(math.radians(CMDphase))
17368  if y1 > 1500:
17369  y1 = xright
17370  elif y1 < -500:
17371  y1 = ycenter - xright
17372  x1 = xcenter + MagRadius*math.cos(math.radians(CMDphase))
17373  if x1 > 1500:
17374  x1 = xright
17375  elif x1 < -500:
17376  x1 = xcenter - xright
17377  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace4, arrow="last", width=TRACEwidth.get())#
17378  if iat_btn.config('text')[-1] == 'ON':
17379  MagRadius = PeakIA / mAperPixel
17380  y1 = ycenter - MagRadius*math.sin(math.radians(CAIphase))
17381  if y1 > 1500:
17382  y1 = xright
17383  elif y1 < -500:
17384  y1 = ycenter - xright
17385  x1 = xcenter + MagRadius*math.cos(math.radians(CAIphase))
17386  if x1 > 1500:
17387  x1 = xright
17388  elif x1 < -500:
17389  x1 = xcenter - xright
17390  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace3, arrow="last", width=TRACEwidth.get())
17391  if ibt_btn.config('text')[-1] == 'ON':
17392  MagRadius = PeakIB / mAperPixel
17393  y1 = ycenter - MagRadius*math.sin(math.radians(CBIphase))
17394  if y1 > 1500:
17395  y1 = xright
17396  elif y1 < -500:
17397  y1 = ycenter - xright
17398  x1 = xcenter + MagRadius*math.cos(math.radians(CBIphase))
17399  if x1 > 1500:
17400  x1 = xright
17401  elif x1 < -500:
17402  x1 = xcenter - xright
17403  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace4, arrow="last", width=TRACEwidth.get())
17404  if MuxScreenStatus.get() == 0:
17405  # plot VA - VB vector
17406  if vabt_btn.config('text')[-1] == 'ON':
17407  MagRadius = PeakVAB / VoltsperPixel
17408 
17409  y1 = ycenter - MagRadius*math.sin(math.radians(CABVphase))
17410  if y1 > 1500:
17411  y1 = xright
17412  elif y1 < -500:
17413  y1 = ycenter - xright
17414  x1 = xcenter + MagRadius*math.cos(math.radians(CABVphase))
17415  if x1 > 1500:
17416  x1 = xright
17417  elif x1 < -500:
17418  x1 = xcenter - xright
17419  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace5, arrow="last", width=TRACEwidth.get())
17420  # plot IA + IB vector
17421  if iapbt_btn.config('text')[-1] == 'ON':
17422  MagRadius = PeakIAB / mAperPixel
17423 
17424  y1 = ycenter - MagRadius*math.sin(math.radians(CABIphase))
17425  if y1 > 1500:
17426  y1 = xright
17427  elif y1 < -500:
17428  y1 = ycenter - xright
17429  x1 = xcenter + MagRadius*math.cos(math.radians(CABIphase))
17430  if x1 > 1500:
17431  x1 = xright
17432  elif x1 < -500:
17433  x1 = xcenter - xright
17434  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace7, arrow="last", width=TRACEwidth.get())
17435 # display warning if input out of range
17436  if OverRangeFlagA == 1:
17437  x = X0LPhA+GRWPhA+10
17438  y = Y0TPhA+GRHPhA-40
17439  PhAca.create_rectangle(x-6, y-6, x+6, y+6, fill="#ff0000")
17440  PhAca.create_text (x+12, y, text="CHA Over Range", anchor=W, fill="#ff0000", font=("arial", FontSize+4 ))
17441  if OverRangeFlagB == 1:
17442  x = X0LPhA+GRWPhA+10
17443  y = Y0TPhA+GRHPhA-10
17444  PhAca.create_rectangle(x-6, y-6, x+6, y+6, fill="#ff0000")
17445  PhAca.create_text (x+12, y, text="CHB Over Range", anchor=W, fill="#ff0000", font=("arial", FontSize+4 ))
17446 # General information on top of the grid
17447  txt = " Sample rate: " + str(SAMPLErate)
17448  txt = txt + " FFT samples: " + str(SMPfft)
17449  txt = txt + " " + FFTwindowname
17450 
17451  x = X0LPhA
17452  y = 12
17453  idTXT = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
17454  #
17455  x = X0LPhA + GRWPhA + 4
17456  y = 24
17457  if ChopMuxMode.get() == 0:
17458  txt = "CA " + ' {0:.3f} '.format(PeakVA) + " RMS V"
17459  TXT9 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace1, font=("arial", FontSize+4 ))
17460  y = y + 24
17461  if MuxScreenStatus.get() == 0:
17462  txt = "CB " + ' {0:.3f} '.format(PeakVB) + " RMS V"
17463  TXT10 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace2, font=("arial", FontSize+4 ))
17464  y = y + 24
17465  else:
17466  if ShowPB_A.get() > 0:
17467  txt = "Mux A " + ' {0:.3f} '.format(PeakVMA) + " RMS V"
17468  TXT10 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace2, font=("arial", FontSize+4 ))
17469  y = y + 24
17470  if ShowPB_B.get() > 0:
17471  txt = "Mux B " + ' {0:.3f} '.format(PeakVMB) + " RMS V"
17472  TXT10 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace6, font=("arial", FontSize+4 ))
17473  y = y + 24
17474  if ShowPB_C.get() > 0:
17475  txt = "Mux C " + ' {0:.3f} '.format(PeakVMC) + " RMS V"
17476  TXT10 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace7, font=("arial", FontSize+4 ))
17477  y = y + 24
17478  if ShowPB_D.get() > 0:
17479  txt = "Mux D " + ' {0:.3f} '.format(PeakVMD) + " RMS V"
17480  TXT10 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace4, font=("arial", FontSize+4 ))
17481  y = y + 24
17482  if vabt_btn.config('text')[-1] == 'ON':
17483  txt = "VA-VB " + ' {0:.3f} '.format(PeakVAB) + " RMS V"
17484  TXT10 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace5, font=("arial", FontSize+4 ))
17485  y = y + 24
17486  if iat_btn.config('text')[-1] == 'ON':
17487  txt = "CA " + ' {0:.2f} '.format(PeakIA) + " RMS mA"
17488  TXT11 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace3, font=("arial", FontSize+4 ))
17489  y = y + 24
17490  if ibt_btn.config('text')[-1] == 'ON':
17491  txt = "CB " + ' {0:.2f} '.format(PeakIB) + " RMS mA"
17492  TXT12 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace4, font=("arial", FontSize+4 ))
17493  y = y + 24
17494  if iapbt_btn.config('text')[-1] == 'ON':
17495  txt = "IA+IB " + ' {0:.2f} '.format(PeakIAB) + " RMS mA"
17496  TXT12 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace7, font=("arial", FontSize+4 ))
17497  y = y + 24
17498  if ChopMuxMode.get() == 0:
17499  txt = "CA V Phase " + ' {0:.1f} '.format(CAVphase) + " Degrees"
17500  TXT13 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace1, font=("arial", FontSize+4 ))
17501  y = y + 24
17502  if MuxScreenStatus.get() == 0:
17503  txt = "CB V Phase " + ' {0:.1f} '.format(CBVphase) + " Degrees"
17504  TXT14 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace2, font=("arial", FontSize+4 ))
17505  y = y + 24
17506  else:
17507  if ShowPB_A.get() > 0:
17508  txt = "Mux A Phase " + ' {0:.1f} '.format(CMAphase) + " Degrees"
17509  TXT14 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace2, font=("arial", FontSize+4 ))
17510  y = y + 24
17511  if ShowPB_B.get() > 0:
17512  txt = "Mux B Phase " + ' {0:.1f} '.format(CMBphase) + " Degrees"
17513  TXT14 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace6, font=("arial", FontSize+4 ))
17514  y = y + 24
17515  if ShowPB_C.get() > 0:
17516  txt = "Mux C Phase " + ' {0:.1f} '.format(CMCphase) + " Degrees"
17517  TXT14 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace7, font=("arial", FontSize+4 ))
17518  y = y + 24
17519  if ShowPB_D.get() > 0:
17520  txt = "Mux D Phase " + ' {0:.1f} '.format(CMDphase) + " Degrees"
17521  TXT14 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace4, font=("arial", FontSize+4 ))
17522  y = y + 24
17523  if vabt_btn.config('text')[-1] == 'ON':
17524  txt = "VA-VB Phase " + ' {0:.1f} '.format(CABVphase) + " Degrees"
17525  TXT13 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace5, font=("arial", FontSize+4 ))
17526  y = y + 24
17527  if iat_btn.config('text')[-1] == 'ON':
17528  txt = "CA I Phase " + ' {0:.1f} '.format(CAIphase) + " Degrees"
17529  TXT15 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace3, font=("arial", FontSize+4 ))
17530  y = y + 24
17531  if ibt_btn.config('text')[-1] == 'ON':
17532  txt = "CB I Phase " + ' {0:.1f} '.format(CBIphase) + " Degrees"
17533  TXT16 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace4, font=("arial", FontSize+4 ))
17534  y = y + 24
17535  if iapbt_btn.config('text')[-1] == 'ON':
17536  txt = "IA+IB Phase " + ' {0:.1f} '.format(CABIphase) + " Degrees"
17537  TXT16 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace7, font=("arial", FontSize+4 ))
17538  y = y + 24
17539  #
17540  if ChopMuxMode.get() == 0:
17541  txt = "CA-V Freq " + ' {0:.1f} '.format(PeakfreqVA) + " Hertz"
17542  TXT17 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
17543  y = y + 24
17544  else:
17545  txt = "Mux A Freq " + ' {0:.1f} '.format(PeakfreqVMA) + " Hertz"
17546  TXT17 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
17547  y = y + 24
17548 #
17549  txt = " "
17550 # print time domin measured period and frequency of displayed channels
17551  if ShowC1_V.get() == 1 or ShowC2_V.get() == 1:
17552  if ETSDisp.get() > 0:
17553  FindRisingEdge(VBuffA[:int(DISsamples)],VBuffB[:int(DISsamples)])
17554  else:
17555  FindRisingEdge(VBuffA,VBuffB)
17556  if ShowC1_V.get() == 1:
17557  if MeasAHW.get() == 1:
17558  txt = txt + " CA Hi Width = " + ' {0:.3f} '.format(CHAHW/Mulx) + " mS "
17559  if MeasALW.get() == 1:
17560  txt = txt + " CA Lo Width = " + ' {0:.3f} '.format(CHALW/Mulx) + " mS "
17561  if MeasADCy.get() == 1:
17562  txt = txt + " CA DutyCycle = " + ' {0:.1f} '.format(CHADCy) + " % "
17563  if MeasAPER.get() == 1:
17564  txt = txt + " CA Period = " + ' {0:.3f} '.format(CHAperiod/Mulx) + " mS "
17565  if MeasAFREQ.get() == 1:
17566  txt = txt + " CA Freq = "
17567  ChaF = float(CHAfreq*Mulx)
17568  if ChaF < 1000:
17569  V1String = ' {0:.2f} '.format(ChaF)
17570  txt = txt + str(V1String) + " Hz "
17571  if ChaF > 1000 and ChaF < 1000000:
17572  V1String = ' {0:.2f} '.format(ChaF/1000)
17573  txt = txt + str(V1String) + " KHz "
17574  if ChaF > 1000000:
17575  V1String = ' {0:.2f} '.format(ChaF/1000000)
17576  txt = txt + str(V1String) + " MHz "
17577  #txt = txt + " CA Freq = " + ' {0:.1f} '.format(CHAfreq) + " Hz "
17578  if ShowC2_V.get() == 1:
17579  if MeasBHW.get() == 1:
17580  txt = txt + " CB Hi Width = " + ' {0:.3f} '.format(CHBHW/Mulx) + " mS "
17581  if MeasBLW.get() == 1:
17582  txt = txt + " CB Lo Width = " + ' {0:.3f} '.format(CHBLW/Mulx) + " mS "
17583  if MeasBDCy.get() == 1:
17584  txt = txt + " CB DutyCycle = " + ' {0:.1f} '.format(CHBDCy) + " % "
17585  if MeasBPER.get() == 1:
17586  txt = txt + " CB Period = " + ' {0:.3f} '.format(CHBperiod/Mulx) + " mS "
17587  if MeasBFREQ.get() == 1:
17588  txt = txt + " CB Freq = "
17589  ChaF = float(CHBfreq*Mulx)
17590  if ChaF < 1000:
17591  V1String = ' {0:.2f} '.format(ChaF)
17592  txt = txt + str(V1String) + " Hz "
17593  if ChaF > 1000 and ChaF < 1000000:
17594  V1String = ' {0:.2f} '.format(ChaF/1000)
17595  txt = txt + str(V1String) + " KHz "
17596  if ChaF > 1000000:
17597  V1String = ' {0:.2f} '.format(ChaF/1000000)
17598  txt = txt + str(V1String) + " MHz "
17599  #txt = txt + " CB Freq = " + ' {0:.1f} '.format(CHBfreq) + " Hz "
17600  if MuxScreenStatus.get() == 0:
17601  if MeasPhase.get() == 1:
17602  txt = txt + " CA-B Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
17603  if MeasDelay.get() == 1:
17604  txt = txt + " CB-A Delay = " + ' {0:.3f} '.format(CHBADelayR1) + " mS "
17605 
17606  x = X0LPhA
17607  y = YBot + int(2.5 *FontSize) #
17608  TXT18 = PhAca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
17609  txt = " "
17610  if ShowC1_V.get() == 1:
17611  # Channel A information
17612  if CHA_RC_HP.get() == 1:
17613  txt = "CHA: HP "
17614  else:
17615  txt = "CHA: "
17616  if MeasDCV1.get() == 1:
17617  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV1)
17618  if MeasMaxV1.get() == 1:
17619  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV1)
17620  if MeasTopV1.get() == 1:
17621  txt = txt + " Top = " + ' {0:.4f} '.format(VATop)
17622  if MeasMinV1.get() == 1:
17623  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV1)
17624  if MeasBaseV1.get() == 1:
17625  txt = txt + " Base = " + ' {0:.4f} '.format(VABase)
17626  if MeasMidV1.get() == 1:
17627  MidV1 = (MaxV1+MinV1)/2.0
17628  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV1)
17629  if MeasPPV1.get() == 1:
17630  PPV1 = MaxV1-MinV1
17631  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV1)
17632  if MeasRMSV1.get() == 1:
17633  txt = txt + " RMS = " + ' {0:.4f} '.format(SV1)
17634  if MeasRMSVA_B.get() == 1:
17635  txt = txt + " A-B RMS = " + ' {0:.4f} '.format(SVA_B)
17636  if MeasDiffAB.get() == 1:
17637  txt = txt + " CA-CB = " + ' {0:.4f} '.format(DCV1-DCV2)
17638  if MeasUserA.get() == 1:
17639  try:
17640  TempValue = eval(UserAString)
17641  V1String = ' {0:.4f} '.format(TempValue)
17642  except:
17643  V1String = "####"
17644  txt = txt + UserALabel + " = " + V1String
17645  if (ShowC1_I.get() == 1 and ShowC1_V.get() == 0):
17646  txt = "CHA: "
17647  elif (ShowC1_I.get() == 1 and ShowC1_V.get() == 1):
17648  txt = txt + "CHA: "
17649 
17650  if ShowC1_I.get() == 1:
17651  if MeasDCI1.get() == 1:
17652  V1String = ' {0:.2f} '.format(DCI1)
17653  txt = txt + " AvgI = " + V1String
17654  if AWGAShape.get() == 0: # if this is a DC measurement calc resistance
17655  try:
17656  Resvalue = (DCV1/DCI1)*1000
17657  txt = txt + " Res = " + ' {0:.1f} '.format(Resvalue)
17658  except:
17659  txt = txt + " Res = OverRange"
17660  if MeasMaxI1.get() == 1:
17661  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI1)
17662  if MeasMinI1.get() == 1:
17663  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI1)
17664  if MeasMidI1.get() == 1:
17665  MidI1 = (MaxI1+MinI1)/2.0
17666  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI1)
17667  if MeasPPI1.get() == 1:
17668  PPI1 = MaxI1-MinI1
17669  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI1)
17670  if MeasRMSI1.get() == 1:
17671  txt = txt + " RMS = " + ' {0:.4f} '.format(SI1)
17672 
17673  x = X0LPhA
17674  y = YBot + int(4*FontSize) #
17675  TXT19 = PhAca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
17676  txt= " "
17677  # Channel B information
17678  if MuxScreenStatus.get() == 1:
17679  txt = "CHB-Mux: "
17680  if Show_CBA.get() > 0:
17681  FindRisingEdge(VBuffA,VBuffMA)
17682  elif Show_CBB.get() > 0:
17683  FindRisingEdge(VBuffA,VBuffMB)
17684  elif Show_CBC.get() > 0:
17685  FindRisingEdge(VBuffA,VBuffMC)
17686  elif Show_CBD.get() > 0:
17687  FindRisingEdge(VBuffA,VBuffMD)
17688  if MeasPhase.get() == 1:
17689  txt = txt + " CA-Mux Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
17690  if MeasDelay.get() == 1:
17691  txt = txt + " Mux-CA Delay = " + ' {0:.3f} '.format(CHBADelayR1) + " mS "
17692  if MeasUserB.get() == 1:
17693  try:
17694  TempValue = eval(UserBString)
17695  V1String = ' {0:.4f} '.format(TempValue)
17696  except:
17697  V1String = "####"
17698  txt = txt + UserBLabel + " = " + V1String
17699  if ShowC2_V.get() == 1:
17700  if CHB_RC_HP.get() == 1:
17701  txt = "CHB: HP "
17702  else:
17703  txt = "CHB: "
17704  if MeasDCV2.get() == 1:
17705  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV2)
17706  if MeasMaxV2.get() == 1:
17707  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV2)
17708  if MeasTopV2.get() == 1:
17709  txt = txt + " Top = " + ' {0:.4f} '.format(VBTop)
17710  if MeasMinV2.get() == 1:
17711  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV2)
17712  if MeasBaseV2.get() == 1:
17713  txt = txt + " Base = " + ' {0:.4f} '.format(VBBase)
17714  if MeasMidV2.get() == 1:
17715  MidV2 = (MaxV2+MinV2)/2.0
17716  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV2)
17717  if MeasPPV2.get() == 1:
17718  PPV2 = MaxV2-MinV2
17719  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV2)
17720  if MeasRMSV2.get() == 1:
17721  txt = txt + " RMS = " + ' {0:.4f} '.format(SV2)
17722  if MeasDiffBA.get() == 1:
17723  txt = txt + " CB-CA = " + ' {0:.4f} '.format(DCV2-DCV1)
17724  if MeasUserB.get() == 1:
17725  try:
17726  TempValue = eval(UserBString)
17727  V1String = ' {0:.4f} '.format(TempValue)
17728  except:
17729  V1String = "####"
17730  txt = txt + UserBLabel + " = " + V1String
17731  if (ShowC2_I.get() == 1 and ShowC2_V.get() == 0):
17732  txt = "CHB: "
17733  elif (ShowC2_I.get() == 1 and ShowC2_V.get() == 1):
17734  txt = txt + "CHB: "
17735  if ShowC2_I.get() == 1:
17736  if MeasDCI2.get() == 1:
17737  V1String = ' {0:.2f} '.format(DCI2)
17738  txt = txt + " AvgI = " + V1String
17739  if AWGBShape.get() == 0: # if this is a DC measurement calc resistance
17740  try:
17741  Resvalue = (DCV2/DCI2)*1000
17742  R1String = ' {0:.1f} '.format(Resvalue)
17743  txt = txt + " Res = " + R1String
17744  except:
17745  txt = txt + " Res = OverRange"
17746  if MeasMaxI2.get() == 1:
17747  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI2)
17748  if MeasMinI2.get() == 1:
17749  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI2)
17750  if MeasMidI2.get() == 1:
17751  MidI2 = (MaxI2+MinI2)/2.0
17752  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI2)
17753  if MeasPPI2.get() == 1:
17754  PPI2 = MaxI2-MinI2
17755  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI2)
17756  if MeasRMSI2.get() == 1:
17757  txt = txt + " RMS = " + ' {0:.4f} '.format(SI2)
17758 
17759  x = X0LPhA
17760  y = YBot + int(5.5 *FontSize) #
17761  TXT20 = PhAca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
17762 #
17763 def BSavePhAData():
17764  global PeakVA, PeakVB, PeakIA, PeakIB
17765  global PeakfreqVA, PeakfreqVB, PeakfreqIA, PeakfreqIB
17766  global PeakVMA, PeakVMB, PeakVMC, PeakVMD
17767  global CAVphase, CBVphase, CAIphase, CBIphase, CABVphase
17768  global CMAphase, CMBphase, CMCphase, CMDphase
17769  global MuxScreenStatus, AppendPhAData, PhADatafilename
17770  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn
17771  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D
17772 
17773  # open file to save data
17774  if AppendPhAData.get() == 0:
17775  PhADatafilename = asksaveasfilename(defaultextension = ".csv", filetypes=[("Comma Separated Values", "*.csv")])
17776  DataFile = open(PhADatafilename, 'a')
17777  DataFile.write( 'Amplitude, Phase, @ ' + str(PeakfreqVA) + ' Hertz\n')
17778 
17779  if vat_btn.config('text')[-1] == 'ON':
17780  DataFile.write( str(PeakVA) + ', ' + str(CAVphase) + ', CA-V\n')
17781  if MuxScreenStatus.get() == 0:
17782  if vbt_btn.config('text')[-1] == 'ON':
17783  DataFile.write( str(PeakVB) + ', ' + str(CBVphase) + ', CB-V\n')
17784  else:
17785  if ShowPB_A.get() > 0:
17786  DataFile.write( str(PeakVMA) + ', ' + str(CMAphase) + ', Mux A\n')
17787  if ShowPB_B.get() > 0:
17788  DataFile.write( str(PeakVMB) + ', ' + str(CMBphase) + ', Mux B\n')
17789  if ShowPB_C.get() > 0:
17790  DataFile.write( str(PeakVMC) + ', ' + str(CMCphase) + ', Mux C\n')
17791  if ShowPB_D.get() > 0:
17792  DataFile.write( str(PeakVMD) + ', ' + str(CMDphase) + ', Mux D\n')
17793  if iat_btn.config('text')[-1] == 'ON':
17794  DataFile.write( str(PeakIA) + ', ' + str(CAIphase) + ', CA-I\n')
17795  if ibt_btn.config('text')[-1] == 'ON':
17796  DataFile.write( str(PeakIB) + ', ' + str(CBIphase) + ', CB-I\n')
17797  DataFile.close()
17798 #
17799 def PlotPhAFromFile():
17800  global CANVASheightPhA, CANVASwidthPhA, PhAca, TRACEwidth, GridWidth, PhAPlotMode
17801  global COLORsignalband, COLORtext, COLORgrid, SmoothCurves # The colors
17802  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5, COLORtrace6, COLORtrace7
17803  global GRWPhA, GRHPhA, X0LPhA, Vdiv, VScale, IScale
17804 # open file to read data from
17805  filename = askopenfilename(defaultextension = ".csv", filetypes=[("Comma Separated Values", "*.csv")])
17806  i = 1
17807  xcenter = GRWPhA/2
17808  ycenter = (GRHPhA/2) + 14
17809  Radius = (GRWPhA-X0LPhA)/(1 + Vdiv.get()*2) # 11
17810  VoltsperPixel = float(VScale.get())/Radius
17811  mAperPixel = float(IScale.get())/Radius
17812  TRadius = Radius * Vdiv.get() # 5
17813  x1 = X0LPhA
17814  x2 = X0LPhA + GRWPhA
17815  PhATrace = []
17816 # Read values from CVS file
17817  try:
17818  CSVFile = open(filename)
17819  dialect = csv.Sniffer().sniff(CSVFile.read(2048))
17820  CSVFile.seek(0)
17821  csv_f = csv.reader(CSVFile, dialect)
17822  for row in csv_f:
17823  try:
17824  PeakMag = float(row[0])
17825  PeakPhase = float(row[1])
17826  if row[2] == "CA-I" or row[2] == "CB-I":
17827  MagRadius = PeakMag / mAperPixel
17828  else:
17829  MagRadius = PeakMag / VoltsperPixel
17830 
17831  y1 = ycenter - MagRadius*math.sin(math.radians(PeakPhase))
17832  if y1 > 1500:
17833  y1 = xright
17834  elif y1 < -500:
17835  y1 = ycenter - xright
17836  x1 = xcenter + MagRadius*math.cos(math.radians(PeakPhase))
17837  if x1 > 1500:
17838  x1 = xright
17839  elif x1 < -500:
17840  x1 = xcenter - xright
17841  if PhAPlotMode.get() == 0:
17842  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace5, arrow="last", width=TRACEwidth.get())
17843  else:
17844  PhATrace.append(x1)
17845  PhATrace.append(y1)
17846  except:
17847  print( 'skipping non-numeric row')
17848  if PhAPlotMode.get() == 1:
17849  PhAca.create_line(PhATrace, fill=COLORtrace5, smooth=SmoothCurves.get(), splinestep=5, width=TRACEwidth.get())
17850  CSVFile.close()
17851  except:
17852  showwarning("WARNING","No such file found or wrong format!")
17853 #
17854 #
17855 def STOREcsvfile(): # Store the trace as CSV file [frequency, magnitude or dB value]
17856  global FFTmemoryA, FFTresultA, SMPfft
17857  global FFTmemoryB, FFTresultB
17858  global PhaseA, PhaseB, freqwindow
17859  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, ShowC1_VdB, ShowC2_VdB
17860 
17861  # Set the TRACEsize variable
17862  if ShowC1_VdB.get() == 1:
17863  TRACEsize = len(FFTresultA) # Set the trace length
17864  elif ShowC2_VdB.get() == 1:
17865  TRACEsize = len(FFTresultB)
17866  if TRACEsize == 0: # If no trace, skip rest of this routine
17867  return()
17868 # ask if save as magnitude or dB
17869  dB = askyesno("Mag or dB: ","Save amplidude data as dB (Yes) or Mag (No):\n", parent=freqwindow)
17870  # Make the file name and open it
17871  if dB == 0:
17872  PSD = askyesno("Mag/Root Hz? ","Save Mag in V/sqrt Hz? (yes) or (No):\n", parent=freqwindow)
17873  tme = strftime("%Y%b%d-%H%M%S", gmtime()) # The time
17874  filename = "Spectrum-" + tme
17875  filename = filename + ".csv"
17876  # open file to save data
17877  filename = asksaveasfilename(initialfile = filename, defaultextension = ".csv",
17878  filetypes=[("Comma Separated Values", "*.csv")], parent=freqwindow)
17879  DataFile = open(filename,'a') # Open output file
17880  HeaderString = 'Frequency-#, '
17881  if ShowC1_VdB.get() == 1:
17882  if dB == 1:
17883  HeaderString = HeaderString + 'CA-dB, '
17884  if dB == 0:
17885  HeaderString = HeaderString + 'CA-Mag, '
17886  if ShowC2_VdB.get() == 1:
17887  if dB == 1:
17888  HeaderString = HeaderString + 'CB-dB, '
17889  if dB == 0:
17890  HeaderString = HeaderString + 'CB-Mag, '
17891  if ShowC1_P.get() == 1:
17892  HeaderString = HeaderString + 'Phase A-B, '
17893  if ShowC2_P.get() == 1:
17894  HeaderString = HeaderString + 'Phase B-A, '
17895  HeaderString = HeaderString + '\n'
17896  DataFile.write( HeaderString )
17897 
17898  FBinWidth = float(SAMPLErate / 2.0) / (TRACEsize - 1) # Frequency step per sample
17899  n = 0
17900 
17901  while n < TRACEsize:
17902  F = n * FBinWidth
17903  txt = str(F)
17904  if ShowC1_VdB.get() == 1:
17905  V = 10 * math.log10(float(FFTresultA[n])) #
17906  if dB == 0:
17907  V = 10.0**(V/20.0) # RMS Volts
17908  if PSD == 1:
17909  V = V/math.sqrt(FBinWidth) # per root Hz
17910  txt = txt + "," + str(V)
17911  if ShowC2_VdB.get() == 1:
17912  V = 10 * math.log10(float(FFTresultB[n])) #
17913  if dB == 0:
17914  V = 10.0**(V/20.0)# RMS Volts
17915  if PSD == 1:
17916  V = V/math.sqrt(FBinWidth) # per root Hz
17917  txt = txt + "," + str(V)
17918  if ShowC1_P.get() == 1:
17919  RelPhase = PhaseA[n]-PhaseB[n]
17920  if RelPhase > 180:
17921  RelPhase = RelPhase - 360
17922  elif RelPhase < -180:
17923  RelPhase = RelPhase + 360
17924  txt = txt + "," + str(RelPhase)
17925  if ShowC2_P.get() == 1:
17926  RelPhase = PhaseB[n]-PhaseA[n]
17927  if RelPhase > 180:
17928  RelPhase = RelPhase - 360
17929  elif RelPhase < -180:
17930  RelPhase = RelPhase + 360
17931  txt = txt + "," + str(RelPhase)
17932  txt = txt + "\n"
17933  DataFile.write(txt)
17934  n = n + 1
17935 
17936  DataFile.close() # Close the file
17937 
17939 def MakeFreqScreen(): # Update the screen with traces and text
17940  global CANVASheightF, CANVASwidthF, SmoothCurvesSA
17941  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
17942  global PeakxM, PeakyM, PeakMdb, PeakfreqM
17943  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
17944  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
17945  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM, PeakIndexA, PeakIndexB, Fsample
17946  global COLORgrid # The colors
17947  global COLORsignalband, COLORtext
17948  global COLORtrace1, COLORtrace2
17949  global FSweepMode, LoopNum, MarkerFreqNum, TRACEwidth, GridWidth
17950  global DBdivindex # Index value
17951  global DBdivlist # dB per division list
17952  global DBlevel # Reference level
17953  global FFTwindow, FFTbandwidth, ZEROstuffing, FFTwindowname
17954  global X0LF # Left top X value
17955  global Y0TF # Left top Y value
17956  global GRWF # Screenwidth
17957  global GRHF # Screenheight
17958  global FontSize
17959  global RUNstatus # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
17960  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, SingleShotSA, HScale, HarmonicMarkers
17961  global SMPfft # number of FFT samples
17962  global SAVScale, SAVPSD, SAvertmaxEntry, SAvertminEntry, SAvertmax, SAvertmin
17963  global StartFreqEntry, StopFreqEntry, PhCenFreqEntry, RelPhaseCenter
17964  global ShowC1_P, ShowC2_P, ShowRA_VdB, ShowRB_VdB, ShowMarker
17965  global ShowRA_P, ShowRB_P, ShowMathSA, FreqDisp, ShowAWGASA, ShowAWGBSA
17966  global ShowFCur, ShowdBCur, FCursor, dBCursor
17967  global T1Fline, T2Fline, T1Pline, T1FRline, T2FRline, TFMline, TFRMline
17968  global T1PRline, T2PRline, TAFline, TBFline
17969  global TRACEaverage # Number of traces for averageing
17970  global FreqTraceMode # 1 normal 2 max 3 average
17971  global Vdiv # Number of vertical divisions
17972 
17973  # Delete all items on the screen
17974  MarkerFreqNum = 0
17975  FBinWidth = float(SAMPLErate / 2.0) / (SMPfft - 1) # Frequency step per sample
17976  Freqca.delete(ALL) # remove all items
17977  try:
17978  StartFrequency = float(StartFreqEntry.get())
17979  except:
17980  StartFreqEntry.delete(0,"end")
17981  StartFreqEntry.insert(0,100)
17982  StartFrequency = 100
17983  try:
17984  StopFrequency = float(StopFreqEntry.get())
17985  except:
17986  StopFreqEntry.delete(0,"end")
17987  StopFreqEntry.insert(0,10000)
17988  StopFrequency = 10000
17989  try:
17990  Phasecenter = int(PhCenFreqEntry.get())
17991  RelPhaseCenter.set(Phasecenter)
17992  except:
17993  PhCenFreqEntry.delete(0,"end")
17994  PhCenFreqEntry.insert(0,0)
17995  RelPhaseCenter.set(0)
17996  Phasecenter = 0
17997  # Draw horizontal grid lines
17998  i = 0
17999  x1 = X0LF
18000  x2 = X0LF + GRWF
18001  if SAVScale.get() == 0: # In dB
18002  while (i <= Vdiv.get()):
18003  y = Y0TF + i * GRHF/Vdiv.get()
18004  Dline = [x1,y,x2,y]
18005  if i == 0 or i == Vdiv.get():
18006  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
18007  else:
18008  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
18009  Vaxis_value = (DBlevel.get() - (i * DBdivlist[DBdivindex.get()]))
18010  Vaxis_label = str(Vaxis_value)
18011  Freqca.create_text(x1-3, y, text=Vaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
18012  if ShowC1_P.get() == 1 or ShowC2_P.get() == 1:
18013  Vaxis_value = ( 180 - ( i * (360 / Vdiv.get())))
18014  Vaxis_value = Vaxis_value + Phasecenter
18015  Vaxis_label = str(Vaxis_value)
18016  Freqca.create_text(x2+3, y, text=Vaxis_label, fill=COLORtrace3, anchor="w", font=("arial", FontSize ))
18017  i = i + 1
18018  else: # In rms V
18019  if SAVScale.get() == 2: # Log Scale
18020  try:
18021  LogVStop = math.log10(SAvertmax)
18022  except:
18023  LogVStop = 0.0
18024  try:
18025  LogVStart = math.log10(SAvertmin)
18026  except:
18027  LogVStart = -10
18028  LogVpixel = (LogVStart - LogVStop) / GRHF
18029  NumDec = LogVStart - LogVStop # number of major grids
18030  Gridpixel = GRHF/NumDec # number of pixels per major grid
18031  V = NumDec
18032  while V <= 0: # Major Grid lines
18033  try:
18034  LogV = math.log10(10**V) # convet to log Volts
18035  y = Y0TF + (LogV/LogVpixel)
18036  except:
18037  y = Y0TF
18038  Dline = [x1,y,x2,y]
18039  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
18040  LNum = LogVStop + V
18041  if LNum == 1.0:
18042  axis_label = "10.0"
18043  elif LNum == 0:
18044  axis_label = "1.0"
18045  elif LNum == -1:
18046  axis_label = "100mV"
18047  elif LNum == -2:
18048  axis_label = "10mV"
18049  elif LNum == -3:
18050  axis_label = "1mV"
18051  elif LNum == -4:
18052  axis_label = "100uV"
18053  elif LNum == -5:
18054  axis_label = "10uV"
18055  elif LNum == -6:
18056  axis_label = "1uV"
18057  elif LNum == -7:
18058  axis_label = "100nV"
18059  elif LNum == -8:
18060  axis_label = "10nV"
18061  else:
18062  axis_label = str(LogVStart+V)
18063  print(LNum)
18064  Freqca.create_text(x1-3, y, text=axis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
18065  J = 2
18066  while J < 10: # Minor Grid lines
18067  ym = y + (Gridpixel*math.log10(J))
18068  Dline = [x1,ym,x2,ym]
18069  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
18070  J = J + 1
18071  V = V + 1
18072  else: # Linear Scale
18073  i = 0
18074  Vper = (SAvertmax - SAvertmin) / Vdiv.get()
18075  while (i < Vdiv.get()+1):
18076  y = Y0TF + i * GRHF/Vdiv.get()
18077  Dline = [x1,y,x2,y]
18078  if i == 0 or i == Vdiv.get():
18079  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
18080  else:
18081  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
18082  axis_value = (SAvertmax - (i * Vper))
18083  axis_label = ' {0:.3f} '.format(axis_value) # str(axis_value)
18084  Freqca.create_text(x1-3, y, text=axis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
18085  i = i + 1
18086  # Draw vertical grid lines
18087  i = 0
18088  y1 = Y0TF
18089  y2 = Y0TF + GRHF
18090  if HScale.get() == 1:
18091  F = 1.0
18092  LogFStop = math.log10(StopFrequency)
18093  try:
18094  LogFStart = math.log10(StartFrequency)
18095  except:
18096  LogFStart = 0.0
18097  LogFpixel = (LogFStop - LogFStart) / GRWF
18098  # draw left and right edges
18099  while F <= StopFrequency:
18100  if F >= StartFrequency:
18101  try:
18102  LogF = math.log10(F) # convet to log Freq
18103  x = X0LF + (LogF - LogFStart)/LogFpixel
18104  except:
18105  x = X0LF
18106  Dline = [x,y1,x,y2]
18107  if F == 1 or F == 10 or F == 100 or F == 1000 or F == 10000 or F == 100000:
18108  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
18109  axis_label = str(F)
18110  Freqca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
18111  else:
18112  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
18113 
18114  if F < 10:
18115  F = F + 1
18116  elif F < 100:
18117  F = F + 10
18118  elif F < 1000:
18119  F = F + 100
18120  elif F < 1000:
18121  F = F + 100
18122  elif F < 10000:
18123  F = F + 1000
18124  elif F < 100000:
18125  F = F + 10000
18126  elif F < 200000:
18127  F = F + 10000
18128  else:
18129  Freqdiv = (StopFrequency - StartFrequency) / 10
18130  while (i < 11):
18131  x = X0LF + i * GRWF/10.0
18132  Dline = [x,y1,x,y2]
18133  if i == 0 or i == 10:
18134  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
18135  else:
18136  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
18137  axis_value = (StartFrequency + (i * Freqdiv))
18138  axis_label = str(axis_value)
18139  Freqca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
18140  i = i + 1
18141  # Draw X - Y cursors if needed
18142  Yconv = float(GRHF) / (Vdiv.get() * DBdivlist[DBdivindex.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
18143  Yc = float(Y0TF) + Yconv * (DBlevel.get()) # Yc is the 0 dBm position, can be outside the screen!
18144  # Vertical conversion factors (level dBs) and border limits
18145  YVconv = float(GRHF) / (SAvertmax - SAvertmin) #
18146  YVc = float(Y0TF) + YVconv * SAvertmax
18147  Fpixel = (StopFrequency - StartFrequency) / GRWF # Frequency step per screen pixel
18148  if ShowFCur.get() > 0:
18149  Dline = [FCursor, Y0TF, FCursor, Y0TF+GRHF]
18150  Freqca.create_line(Dline, dash=(3,4), fill=COLORtrigger, width=GridWidth.get())
18151  # Horizontal conversion factors (frequency Hz) and border limits
18152  if HScale.get() == 1:
18153  LogFStop = math.log10(StopFrequency)
18154  try:
18155  LogFStart = math.log10(StartFrequency)
18156  except:
18157  LogFStart = 0.0
18158  LogFpixel = (LogFStop - LogFStart) / GRWF
18159  xfreq = 10**(((FCursor-X0LF)*LogFpixel) + LogFStart)
18160  else:
18161  Fpixel = (StopFrequency - StartFrequency) / GRWF # Frequency step per screen pixel
18162  xfreq = ((FCursor-X0LF)*Fpixel)+StartFrequency
18163  XFString = ' {0:.2f} '.format(xfreq)
18164  V_label = XFString + " Hz"
18165  Freqca.create_text(FCursor+1, Y0TF+GRHF+6, text=V_label, fill=COLORtext, anchor="n", font=("arial", FontSize ))
18166  #Freqca.create_text(FCursor+1, dBCursor-5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
18167 #
18168  if ShowdBCur.get() > 0:
18169  Dline = [X0LF, dBCursor, X0LF+GRWF, dBCursor]
18170  Freqca.create_line(Dline, dash=(3,4), fill=COLORtrigger, width=GridWidth.get())
18171  if SAVScale.get() == 0: # In dB
18172  yvdB = ((Yc-dBCursor)/Yconv)
18173  VdBString = ' {0:.1f} '.format(yvdB)
18174  V_label = VdBString + " dBV"
18175  elif SAVScale.get() == 1: # Lin Scale
18176  yvdB = ((YVc-dBCursor)/YVconv)
18177  VdBString = ' {0:.3f} '.format(yvdB)
18178  V_label = VdBString + " Vrms"
18179  else: # Log Scale
18180  LogVpixel = (LogVStop - LogVStart) / GRHF
18181  Vlog = ((YVc - dBCursor) * LogVpixel) + LogVStart
18182  yvdB = 10**Vlog
18183  VdBString = ' {:.2e} '.format(yvdB)
18184  V_label = VdBString + " Vrms"
18185 
18186  Freqca.create_text(X0LF+GRWF-5, dBCursor, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
18187  #
18188  SmoothBool = SmoothCurvesSA.get()
18189  # Draw traces
18190  if len(T1Fline) > 4: # Avoid writing lines with 1 coordinate
18191  # Write the trace CHA
18192  if OverRangeFlagA == 1:
18193  Freqca.create_line(T1Fline, fill=COLORsignalband, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
18194  else:
18195  Freqca.create_line(T1Fline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
18196  if ShowMarker.get() > 0:
18197  k = 1
18198  while k <= HarmonicMarkers.get():
18199  FreqA = k*PeakIndexA*Fsample
18200  #
18201  if SAVScale.get() == 0: # In dB
18202  if SAVPSD.get() == 1:
18203  try:
18204  dbA = 10 * math.log10(float(FFTresultA[PeakIndexA*k])/math.sqrt(FBinWidth))
18205  except:
18206  dbA = -100
18207  else:
18208  try:
18209  dbA = 10 * math.log10(float(FFTresultA[PeakIndexA*k]))
18210  except:
18211  dbA = -100
18212  if ShowMarker.get() == 2 and k > 1:
18213  Peak_label = ' {0:.2f} '.format(dbA - PeakdbA) + ',' + ' {0:.1f} '.format(FreqA - PeakfreqA)
18214  else:
18215  Peak_label = ' {0:.2f} '.format(dbA) + ',' + ' {0:.1f} '.format(FreqA)
18216  yA = Yc - Yconv * dbA
18217  else: # Volts Scale
18218  try:
18219  dbA = 10 * math.log10(float(FFTresultA[PeakIndexA*k])) # Convert power to DBs
18220  except:
18221  dbA = -100
18222  V = 10.0**(dbA/20.0)# convert back to RMS Volts
18223  PeakV = 10.0**(PeakdbA/20.0)# convert back to RMS Volts
18224  if SAVPSD.get() == 1: # per root Hz
18225  V = V/math.sqrt(FBinWidth)
18226  PeakV = PeakV/math.sqrt(FBinWidth) # per root Hz
18227  if SAVScale.get() == 2: # Log Scale
18228  LogVpixel = (LogVStop - LogVStart) / GRHF
18229  try:
18230  LogV = math.log10(V) # convet to log Volts
18231  yA = YVc - (LogV - LogVStart)/LogVpixel
18232  except:
18233  yA = YVc - YVconv * V
18234  if ShowMarker.get() == 2 and k > 1:
18235  Peak_label = ' {0:.2e} '.format(V - PeakV) + ',' + ' {0:.1f} '.format(FreqA - PeakfreqA)
18236  else:
18237  Peak_label = ' {0:.2e} '.format(V) + ',' + ' {0:.1f} '.format(FreqA)
18238  else: # Lin Scale
18239  if ShowMarker.get() == 2 and k > 1:
18240  Peak_label = ' {0:.2f} '.format(V - PeakV) + ',' + ' {0:.1f} '.format(FreqA - PeakfreqA)
18241  else:
18242  Peak_label = ' {0:.2f} '.format(V) + ',' + ' {0:.1f} '.format(FreqA)
18243  yA = YVc - YVconv * V
18244  #
18245  if HScale.get() == 1:
18246  try:
18247  LogF = math.log10(FreqA) # convet to log Freq
18248  xA = X0LF + int((LogF - LogFStart)/LogFpixel)
18249  except:
18250  xA = X0LF
18251  else:
18252  xA = X0LF+int((FreqA - StartFrequency)/Fpixel)# +StartFrequency
18253 
18254  Freqca.create_text(xA, yA, text=Peak_label, fill=COLORtrace1, anchor="s", font=("arial", FontSize ))
18255  k = k + 1
18256 
18257  if len(T2Fline) > 4: # Avoid writing lines with 1 coordinate
18258  # Write the trace CHB
18259  if OverRangeFlagB == 1:
18260  Freqca.create_line(T2Fline, fill=COLORsignalband, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
18261  else:
18262  Freqca.create_line(T2Fline, fill=COLORtrace2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
18263  if ShowMarker.get() > 0:
18264  k = 1
18265  while k <= HarmonicMarkers.get():
18266  FreqB = k*PeakIndexB*Fsample
18267  #
18268  if SAVScale.get() == 0: # In dB
18269  if SAVPSD.get() == 1:
18270  try:
18271  dbB = 10 * math.log10(float(FFTresultB[PeakIndexB*k])/math.sqrt(FBinWidth))
18272  except:
18273  dbB = -100
18274  else:
18275  try:
18276  dbB = 10 * math.log10(float(FFTresultB[PeakIndexB*k]))
18277  except:
18278  dbb = -100
18279  if ShowMarker.get() == 2 and k > 1:
18280  Peak_label = ' {0:.2f} '.format(dbB - PeakdbB) + ',' + ' {0:.1f} '.format(FreqB - PeakfreqB)
18281  else:
18282  Peak_label = ' {0:.2f} '.format(dbB) + ',' + ' {0:.1f} '.format(FreqB)
18283  yB = Yc - Yconv * dbB
18284  else: # Volts Scale
18285  try:
18286  dbB = 10 * math.log10(float(FFTresultB[PeakIndexB*k])) # Convert power to DBs
18287  except:
18288  dbB = -100
18289  V = 10.0**(dbB/20.0)# convert back to RMS Volts
18290  PeakV = 10.0**(PeakdbB/20.0)# convert back to RMS Volts
18291  if SAVPSD.get() == 1: # per root Hz
18292  V = V/math.sqrt(FBinWidth)
18293  PeakV = PeakV/math.sqrt(FBinWidth) # per root Hz
18294  if SAVScale.get() == 2: # Log Scale
18295  LogVpixel = (LogVStop - LogVStart) / GRHF
18296  try:
18297  LogV = math.log10(V) # convet to log Volts
18298  yB = YVc - (LogV - LogVStart)/LogVpixel
18299  except:
18300  yB = YVc - YVconv * V
18301  if ShowMarker.get() == 2 and k > 1:
18302  Peak_label = ' {0:.2e} '.format(V - PeakV) + ',' + ' {0:.1f} '.format(FreqB - PeakfreqB)
18303  else:
18304  Peak_label = ' {0:.2e} '.format(V) + ',' + ' {0:.1f} '.format(FreqB)
18305  else: # Lin Scale
18306  if ShowMarker.get() == 2 and k > 1:
18307  Peak_label = ' {0:.2f} '.format(V - PeakV) + ',' + ' {0:.1f} '.format(FreqB - PeakfreqB)
18308  else:
18309  Peak_label = ' {0:.2f} '.format(V) + ',' + ' {0:.1f} '.format(FreqB)
18310  yB = YVc - YVconv * V
18311  #
18312  if HScale.get() == 1:
18313  try:
18314  LogF = math.log10(FreqB) # convet to log Freq
18315  xB = X0LF + int((LogF - LogFStart)/LogFpixel)
18316  except:
18317  xB = X0LF
18318  else:
18319  xB = X0LF+int((FreqB - StartFrequency)/Fpixel)# +StartFrequency
18320 
18321  Freqca.create_text(xB, yB, text=Peak_label, fill=COLORtrace2, anchor="s", font=("arial", FontSize ))
18322  k = k + 1
18323 #
18324  if len(T1Pline) > 4: # Avoid writing lines with 1 coordinate
18325  # Write the phase trace A-B
18326  Freqca.create_line(T1Pline, fill=COLORtrace3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
18327  if len(T2Pline) > 4: # Avoid writing lines with 1 coordinate
18328  # Write the phase trace A-B
18329  Freqca.create_line(T2Pline, fill=COLORtrace4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
18330  if ShowAWGASA.get() > 0 and len(TAFline) > 4: # Write the AWG trace A if active
18331  Freqca.create_line(TAFline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
18332  if ShowAWGBSA.get() > 0 and len(TBFline) > 4: # Write the AWG trace B if active
18333  Freqca.create_line(TBFline, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
18334  if ShowRA_VdB.get() == 1 and len(T1FRline) > 4: # Write the ref trace A if active
18335  Freqca.create_line(T1FRline, fill=COLORtraceR1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
18336  if ShowMarker.get() == 1:
18337  Peak_label = ' {0:.2f} '.format(PeakdbRA) + ',' + ' {0:.1f} '.format(PeakfreqRA)
18338  Freqca.create_text(PeakxRA, PeakyRA, text=Peak_label, fill=COLORtraceR1, anchor="s", font=("arial", FontSize ))
18339  if ShowRB_VdB.get() == 1 and len(T2FRline) > 4: # Write the ref trace B if active
18340  Freqca.create_line(T2FRline, fill=COLORtraceR2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
18341  if ShowMarker.get() == 1:
18342  Peak_label = ' {0:.2f} '.format(PeakdbRB) + ',' + ' {0:.1f} '.format(PeakfreqRB)
18343  Freqca.create_text(PeakxRB, PeakyRB, text=Peak_label, fill=COLORtraceR2, anchor="s", font=("arial", FontSize ))
18344  if ShowRA_P.get() == 1 and len(T1PRline) > 4: # Write the ref trace A if active
18345  Freqca.create_line(T1PRline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
18346  if ShowRB_P.get() == 1 and len(T2PRline) > 4: # Write the ref trace A if active
18347  Freqca.create_line(T2PRline, fill=COLORtraceR4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
18348  if ShowMathSA.get() > 0 and len(TFMline) > 4: # Write the Math trace if active
18349  Freqca.create_line(TFMline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
18350  if ShowMarker.get() ==1:
18351  Peak_label = ' {0:.2f} '.format(PeakMdb) + ',' + ' {0:.1f} '.format(PeakfreqM)
18352  Freqca.create_text(PeakxM, PeakyM, text=Peak_label, fill=COLORtrace5, anchor="s", font=("arial", FontSize ))
18353  if ShowRMath.get() == 1 and len(TFRMline) > 4: # Write the ref math trace if active
18354  Freqca.create_line(TFRMline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
18355  if ShowMarker.get() ==1:
18356  Peak_label = ' {0:.2f} '.format(PeakRMdb) + ',' + ' {0:.1f} '.format(PeakfreqRM)
18357  Freqca.create_text(PeakxRM, PeakyRM, text=Peak_label, fill=COLORtraceR5, anchor="s", font=("arial", FontSize ))
18358  # General information on top of the grid
18359 
18360  txt = " Sample rate: " + str(SAMPLErate)
18361  txt = txt + " FFT samples: " + str(SMPfft)
18362 
18363  txt = txt + " " + FFTwindowname
18364 
18365  x = X0LF
18366  y = 12
18367  idTXT = Freqca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
18368 
18369  # Start and stop frequency and dB/div and trace mode
18370  txt = str(StartFrequency) + " to " + str(StopFrequency) + " Hz"
18371  txt = txt + " " + str(DBdivlist[DBdivindex.get()]) + " dB/div"
18372  txt = txt + " Level: " + str(DBlevel.get()) + " dB "
18373  if FFTwindow.get() < 7:
18374  txt = txt + " FFT Bandwidth =" + ' {0:.2f} '.format(FFTbandwidth)
18375  else:
18376  txt = txt + " FFT Bandwidth = ???"
18377 
18378  x = X0LF
18379  y = Y0TF+GRHF+23
18380  idTXT = Freqca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
18381 
18382  if FreqTraceMode.get() == 1:
18383  txt ="Normal mode "
18384 
18385  if FreqTraceMode.get() == 2:
18386  txt = "Peak hold mode "
18387 
18388  if FreqTraceMode.get() == 3:
18389  txt = "Power average mode (" + str(TRACEaverage.get()) + ") "
18390 
18391  if ZEROstuffing.get() > 0:
18392  txt = txt + "Zero Stuffing = " + str(ZEROstuffing.get())
18393  # Runstatus and level information
18394  if (RUNstatus.get() == 0) and (SingleShotSA.get() == 0):
18395  txt = txt + " Stopped "
18396  elif SingleShotSA.get() == 1:
18397  txt = txt + " Single Shot Trace "
18398  else:
18399  if FreqDisp.get() == 1:
18400  txt = txt + " Running "
18401  else:
18402  txt = txt + " Display off "
18403  x = X0LF
18404  y = Y0TF+GRHF+34
18405  IDtxt = Freqca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize ))
18406 
18407 def INITIALIZEstart():
18408  global SMPfft, FFTwindow
18409  global SMPfftpwrTwo, BodeDisp
18410  global TRACEresetFreq, FreqTraceMode, LoopNum, FSweepMode, FSweepCont
18411 
18412  # First some subroutines to set specific variables
18413  if BodeDisp.get() == 0:
18414  if FFTwindow.get() != 8:
18415  SMPfft = 2 ** int(SMPfftpwrTwo.get()) # Calculate the number of FFT samples from SMPfftpwrtwo
18416 
18418  if FreqTraceMode.get() == 1 and TRACEresetFreq == False:
18419  TRACEresetFreq = True # Clear the memory for averaging or peak
18420  if FreqTraceMode.get() == 2 and LoopNum.get() == 1 and FSweepMode.get() > 0 and FSweepCont.get() == 0 and BodeDisp.get() >0:
18421  TRACEresetFreq = True # Clear the memory for peak hold when using sweep generator
18422 
18423 def CALCFFTwindowshape(): # Make the FFTwindowshape for the windowing function
18424  global FFTbandwidth # The FFT bandwidth
18425  global FFTwindow # Which FFT window number is selected
18426  global FFTwindowname # The name of the FFT window function
18427  global FFTwindowshape # The window shape
18428  global AWGSAMPLErate, SAMPLErate, BaseSampleRate # The sample rate
18429  global SMPfft # Number of FFT samples
18430  global LastWindow, LastSMPfft
18431 
18432  if LastWindow == FFTwindow.get() and LastSMPfft == SMPfft:
18433  # recalculate window only if something changed
18434  return
18435  # FFTname and FFTbandwidth in milliHz
18436  FFTwindowname = "No such window"
18437  FFTbw = 0
18438 
18439  if FFTwindow.get() == 0:
18440  FFTwindowname = " Rectangular (no) window (B=1) "
18441  FFTbw = 1.0
18442 
18443  if FFTwindow.get() == 1:
18444  FFTwindowname = " Cosine window (B=1.24) "
18445  FFTbw = 1.24
18446 
18447  if FFTwindow.get() == 2:
18448  FFTwindowname = " Triangular window (B=1.33) "
18449  FFTbw = 1.33
18450 
18451  if FFTwindow.get() == 3:
18452  FFTwindowname = " Hann window (B=1.5) "
18453  FFTbw = 1.5
18454 
18455  if FFTwindow.get() == 4:
18456  FFTwindowname = " Blackman window (B=1.73) "
18457  FFTbw = 1.73
18458 
18459  if FFTwindow.get() == 5:
18460  FFTwindowname = " Nuttall window (B=2.02) "
18461  FFTbw = 2.02
18462 
18463  if FFTwindow.get() == 6:
18464  FFTwindowname = " Flat top window (B=3.77) "
18465  FFTbw = 3.77
18466 
18467  if FFTwindow.get() == 7:
18468  FFTwindowname = FFTUserWindowString
18469  FFTbw = 0.0
18470  try:
18471  FFTwindowshape = eval(FFTUserWindowString)
18472  except:
18473  FFTwindowshape = numpy.ones(SMPfft) # Initialize with ones
18474  print( "Filling FFT window with Ones")
18475  elif FFTwindow.get() == 8: # window shape array read from csv file
18476  FFTwindowname = "Window Shape From file"
18477  FFTbw = 0.0
18478  else:
18479  FFTbandwidth = int(FFTbw * (SAMPLErate/2.0) / float(SMPfft))
18480  # Calculate the shape
18481  FFTwindowshape = numpy.ones(SMPfft) # Initialize with ones
18482  n = 0
18483  while n < SMPfft:
18484  # Cosine window function - medium-dynamic range B=1.24
18485  if FFTwindow.get() == 1:
18486  w = math.sin(math.pi * n / (SMPfft - 1))
18487  FFTwindowshape[n] = w * 1.571
18488  # Triangular non-zero endpoints - medium-dynamic range B=1.33
18489  if FFTwindow.get() == 2:
18490  w = (2.0 / SMPfft) * ((SMPfft/ 2.0) - abs(n - (SMPfft - 1) / 2.0))
18491  FFTwindowshape[n] = w * 2.0
18492  # Hann window function - medium-dynamic range B=1.5
18493  if FFTwindow.get() == 3:
18494  w = 0.5 - 0.5 * math.cos(2 * math.pi * n / (SMPfft - 1))
18495  FFTwindowshape[n] = w * 2.000
18496  # Blackman window, continuous first derivate function - medium-dynamic range B=1.73
18497  if FFTwindow.get() == 4:
18498  w = 0.42 - 0.5 * math.cos(2 * math.pi * n / (SMPfft - 1)) + 0.08 * math.cos(4 * math.pi * n / (SMPfft - 1))
18499  FFTwindowshape[n] = w * 2.381
18500  # Nuttall window, continuous first derivate function - high-dynamic range B=2.02
18501  if FFTwindow.get() == 5:
18502  w = 0.355768 - 0.487396 * math.cos(2 * math.pi * n / (SMPfft - 1)) + 0.144232 * math.cos(4 * math.pi * n / (SMPfft - 1))- 0.012604 * math.cos(6 * math.pi * n / (SMPfft - 1))
18503  FFTwindowshape[n] = w * 2.811
18504  # Flat top window, medium-dynamic range, extra wide bandwidth B=3.77
18505  if FFTwindow.get() == 6:
18506  w = 1.0 - 1.93 * math.cos(2 * math.pi * n / (SMPfft - 1)) + 1.29 * math.cos(4 * math.pi * n / (SMPfft - 1))- 0.388 * math.cos(6 * math.pi * n / (SMPfft - 1)) + 0.032 * math.cos(8 * math.pi * n / (SMPfft - 1))
18507  FFTwindowshape[n] = w * 1.000
18508  n = n + 1
18509  LastWindow = FFTwindow.get()
18510  LastSMPfft = SMPfft
18511 
18512 def BUserFFTwindow():
18513  global FFTUserWindowString, freqwindow
18514 
18515  TempString = FFTUserWindowString
18516  FFTUserWindowString = askstring("User FFT Window", "Current User Window: " + FFTUserWindowString + "\n\nNew Window:\n", initialvalue=FFTUserWindowString, parent=freqwindow)
18517  if (FFTUserWindowString == None): # If Cancel pressed, then None
18518  FFTUserWindowString = TempString
18519 
18520 def BFileFFTwindow():
18521  global FFTwindowshape, SMPfft, LastSMPfft, FFTwindow, LastWindow
18522 
18523  # Read values from CVS file
18524  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=freqwindow)
18525  try:
18526  CSVFile = open(filename)
18527  csv_f = csv.reader(CSVFile)
18528  FFTwindowshape = []
18529  for row in csv_f:
18530  try:
18531  FFTwindowshape.append(float(row[0]))
18532  except:
18533  print( 'skipping non-numeric row')
18534  FFTwindowshape = numpy.array(FFTwindowshape)
18535  CSVFile.close()
18536  SMPfft = len(FFTwindowshape)
18537  LastSMPfft = SMPfft
18538  LastWindow = FFTwindow.get()
18539  print( SMPfft)
18540  except:
18541  showwarning("WARNING","No such file found or wrong format!")
18542 #
18543 def onCanvasFreqRightClick(event):
18544  global ShowFCur, ShowdBCur, FCursor, dBCursor, RUNstatus, Freqca
18545 
18546  FCursor = event.x
18547  dBCursor = event.y
18548  if RUNstatus.get() == 0:
18550  Freqca.bind('<MouseWheel>', onCanvasFreqClickScroll)
18551  Freqca.bind("<Button-4>", onCanvasFreqClickScroll)# with Linux OS
18552  Freqca.bind("<Button-5>", onCanvasFreqClickScroll)
18553 #
18554 def onCanvasFreqClickScroll(event):
18555  global ShowFCur, ShowdBCur, FCursor, dBCursor, RUNstatus, Freqca
18556 
18557  if event.widget == Freqca:
18558  ShiftKeyDwn = event.state & 1
18559  if ShowFCur.get() > 0 and ShiftKeyDwn == 0:
18560  # respond to Linux or Windows wheel event
18561  if event.num == 5 or event.delta == -120:
18562  FCursor -= 1
18563  if event.num == 4 or event.delta == 120:
18564  FCursor += 1
18565  elif ShowdBCur.get() > 0 or ShiftKeyDwn == 1:
18566  # respond to Linux or Windows wheel event
18567  if event.num == 5 or event.delta == -120:
18568  dBCursor += 1
18569  if event.num == 4 or event.delta == 120:
18570  dBCursor -= 1
18571  if RUNstatus.get() == 0:
18573 #
18574 def onCanvasFreqLeftClick(event):
18575  global X0LF # Left top X value
18576  global Y0TF # Left top Y value
18577  global GRWF # Screenwidth
18578  global GRHF # Screenheight
18579  global FontSize
18580  global Freqca, MarkerLoc, SAMPLErate, BaseSampleRate
18581  global COLORgrid, COLORtext, HScale, ShowC1_VdB, ShowC2_VdB
18582  global COLORtrace1, COLORtrace2, StartFreqEntry, StopFreqEntry
18583  global AWGSAMPLErate, RUNstatus, COLORtext, MarkerFreqNum, PrevdBV, PrevF
18584  global SAVScale, SAVPSD, SAvertmaxEntry, SAvertminEntry, SAvertmax, SAvertmin
18585 
18586  if (RUNstatus.get() == 0):
18587  MarkerFreqNum = MarkerFreqNum + 1
18588  COLORmarker = COLORgrid
18589  if ShowC1_VdB.get() == 1:
18590  COLORmarker = COLORtrace1
18591  elif ShowC2_VdB.get() == 1:
18592  COLORmarker = COLORtrace2
18593  try:
18594  StartFrequency = float(StartFreqEntry.get())
18595  except:
18596  StartFreqEntry.delete(0,"end")
18597  StartFreqEntry.insert(0,100)
18598  StartFrequency = 100
18599  try:
18600  StopFrequency = float(StopFreqEntry.get())
18601  except:
18602  StopFreqEntry.delete(0,"end")
18603  StopFreqEntry.insert(0,100)
18604  StopFrequency = 100
18605  # draw X at marker point and number
18606  Freqca.create_line(event.x-4, event.y-4,event.x+4, event.y+5, fill=COLORmarker)
18607  Freqca.create_line(event.x+4, event.y-4,event.x-4, event.y+5, fill=COLORmarker)
18608  Freqca.create_text(event.x+4, event.y, text=str(MarkerFreqNum), fill=COLORmarker, anchor="w", font=("arial", FontSize ))
18609  # Vertical conversion factors (level dBs) and border limits
18610  Yconv = float(GRHF) / (Vdiv.get() * DBdivlist[DBdivindex.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
18611  YVconv = float(GRHF) / (SAvertmax - SAvertmin) # * Vdiv.get()
18612  Yc = float(Y0TF) + Yconv * (DBlevel.get()) # Yc is the 0 dBm position, can be outside the screen!
18613  YVc = float(Y0TF) + YVconv * SAvertmax
18614  Yphconv = float(GRHF) / 360
18615  Yp = float(Y0TF) + Yphconv + 180
18616  # Horizontal conversion factors (frequency Hz) and border limits
18617  if HScale.get() == 1:
18618  LogFStop = math.log10(StopFrequency)
18619  try:
18620  LogFStart = math.log10(StartFrequency)
18621  except:
18622  LogFStart = 0.0
18623  LogFpixel = (LogFStop - LogFStart) / GRWF
18624  xfreq = 10**(((event.x-X0LF)*LogFpixel) + LogFStart)
18625  else:
18626  Fpixel = (StopFrequency - StartFrequency) / GRWF # Frequency step per screen pixel
18627  xfreq = ((event.x-X0LF)*Fpixel)+StartFrequency
18628  #
18629  try:
18630  LogVStop = math.log10(SAvertmax)
18631  except:
18632  LogVStop = 0.0
18633  try:
18634  LogVStart = math.log10(SAvertmin)
18635  except:
18636  LogVStart = -10
18637  LogVpixel = (LogVStop - LogVStart) / GRHF
18638  #
18639  XFString = ' {0:.2f} '.format(xfreq)
18640  if SAVScale.get() == 0:
18641  yvdB = ((Yc-event.y)/Yconv)
18642  VdBString = ' {0:.3f} '.format(yvdB)
18643  V_label = str(MarkerFreqNum) + " " + XFString + " Hz, " + VdBString + " dBV"
18644  else:
18645  if SAVScale.get() == 1:
18646  yvdB = ((YVc-event.y)/YVconv)
18647  VdBString = ' {0:.3f} '.format(yvdB)
18648  else:
18649  Vlog = ((YVc - event.y) * LogVpixel) + LogVStart
18650  yvdB = 10**Vlog
18651  VdBString = ' {:.2e} '.format(yvdB)
18652  V_label = str(MarkerFreqNum) + " " + XFString + " Hz, " + VdBString + " Vrms"
18653 
18654  if MarkerFreqNum > 1:
18655  DeltaV = ' {0:.3f} '.format(yvdB-PrevdBV)
18656  DeltaF = ' {0:.2f} '.format(xfreq-PrevF)
18657  if SAVScale.get() == 0:
18658  DeltaV = ' {0:.3f} '.format(yvdB-PrevdBV)
18659  V_label = V_label + " Delta " + DeltaF + " Hz, " + DeltaV + " dBV"
18660  else:
18661  if SAVScale.get() == 1:
18662  DeltaV = ' {0:.3f} '.format(yvdB-PrevdBV)
18663  else:
18664  DeltaV = ' {0:.2e} '.format(yvdB-PrevdBV)
18665  V_label = V_label + " Delta " + DeltaF + " Hz, " + DeltaV + " Vrms"
18666  x = X0LF + 5
18667  y = Y0TF + 3 + (MarkerFreqNum*10)
18668  Justify = 'w'
18669  if MarkerLoc == 'UR' or MarkerLoc == 'ur':
18670  x = X0LF + GRWF - 5
18671  y = Y0TF + 3 + (MarkerFreqNum*10)
18672  Justify = 'e'
18673  if MarkerLoc == 'LL' or MarkerLoc == 'll':
18674  x = X0LF + 5
18675  y = Y0TF + GRHF + 3 - (MarkerFreqNum*10)
18676  Justify = 'w'
18677  if MarkerLoc == 'LR' or MarkerLoc == 'lr':
18678  x = X0LF + GRWF - 5
18679  y = Y0TF + GRHF + 3 - (MarkerFreqNum*10)
18680  Justify = 'e'
18681  Freqca.create_text(x, y, text=V_label, fill=COLORmarker, anchor=Justify, font=("arial", FontSize ))
18682  PrevdBV = yvdB
18683  PrevF = xfreq
18684 #
18685 def onCanvasSAOne(event):
18686  global ShowC1_VdB
18687  if ShowC1_VdB.get() == 0:
18688  ShowC1_VdB.set(1)
18689  else:
18690  ShowC1_VdB.set(0)
18691 #
18692 def onCanvasSATwo(event):
18693  global ShowC2_VdB
18694  if ShowC2_VdB.get() == 0:
18695  ShowC2_VdB.set(1)
18696  else:
18697  ShowC2_VdB.set(0)
18698 #
18699 def onCanvasSAThree(event):
18700  global ShowC1_P
18701  if ShowC1_P.get() == 0:
18702  ShowC1_P.set(1)
18703  else:
18704  ShowC1_P.set(0)
18705 #
18706 def onCanvasSAFour(event):
18707  global ShowC2_P
18708  if ShowC2_P.get() == 0:
18709  ShowC2_P.set(1)
18710  else:
18711  ShowC2_P.set(0)
18712 #
18713 def onCanvasSAFive(event):
18714  global ShowMarker
18715  if ShowMarker.get() == 0:
18716  ShowMarker.set(1)
18717  else:
18718  ShowMarker.set(0)
18719 #
18720 def onCanvasSASix(event):
18721  global ShowRA_VdB
18722  if ShowRA_VdB.get() == 0:
18723  ShowRA_VdB.set(1)
18724  else:
18725  ShowRA_VdB.set(0)
18726 #
18727 def onCanvasSASeven(event):
18728  global ShowRB_VdB
18729  if ShowRB_VdB.get() == 0:
18730  ShowRB_VdB.set(1)
18731  else:
18732  ShowRB_VdB.set(0)
18733 #
18734 def onCanvasSAEight(event):
18735  global ShowMathSA
18736  ShowMathSA.set(2)
18737 #
18738 def onCanvasSANine(event):
18739  global ShowMathSA
18740  ShowMathSA.set(1)
18741 #
18742 def onCanvasSAZero(event):
18743  global ShowMathSA
18744  ShowMathSA.set(0)
18745 #
18746 def onCanvasSASnap(event):
18747  BSTOREtraceSA()
18748 #
18749 def onCanvasSANormal(event):
18750  BNormalmode()
18751 #
18752 def onCanvasSAPeak(event):
18753  BPeakholdmode()
18754 
18755 def onCanvasSAReset(event):
18756  BResetFreqAvg()
18757 #
18758 def onCanvasSAAverage(event):
18759  BAveragemode()
18760 #
18761 def onCanvasShowFcur(event):
18762  global ShowFCur
18763  if ShowFCur.get() == 0:
18764  ShowFCur.set(1)
18765  else:
18766  ShowFCur.set(0)
18767 #
18768 def onCanvasShowdBcur(event):
18769  global ShowdBCur
18770  if ShowdBCur.get() == 1:
18771  ShowdBCur.set(0)
18772  else:
18773  ShowdBCur.set(1)
18774 #
18775 def onCanvasShowPcur(event):
18776  global ShowdBCur
18777  if ShowdBCur.get() == 2:
18778  ShowdBCur.set(0)
18779  else:
18780  ShowdBCur.set(2)
18781 #
18782 def onCanvasBodeRightClick(event):
18783  global ShowBPCur, ShowBdBCur, BPCursor, BdBCursor, RUNstatus, Bodeca
18784 
18785  BPCursor = event.x
18786  BdBCursor = event.y
18787  if RUNstatus.get() == 0:
18789  #Bodeca.bind_all('<MouseWheel>', onCanvasBodeClickScroll)
18790  Bodeca.bind('<MouseWheel>', onCanvasBodeClickScroll)
18791  Bodeca.bind("<Button-4>", onCanvasBodeClickScroll)# with Linux OS
18792  Bodeca.bind("<Button-5>", onCanvasBodeClickScroll)
18793 #
18794 def onCanvasBodeClickScroll(event):
18795  global ShowBPCur, ShowBdBCur, BPCursor, BdBCursor, RUNstatus
18796 
18797  # print event.state
18798  shift_key = event.state & 1
18799  if ShowBPCur.get() > 0 and shift_key == 0:
18800  # respond to Linux or Windows wheel event
18801  if event.num == 5 or event.delta == -120:
18802  BPCursor -= 1
18803  if event.num == 4 or event.delta == 120:
18804  BPCursor += 1
18805  elif ShowBdBCur.get() > 0 or shift_key == 1:
18806  # respond to Linux or Windows wheel event
18807  if event.num == 5 or event.delta == -120:
18808  BdBCursor += 1
18809  if event.num == 4 or event.delta == 120:
18810  BdBCursor -= 1
18811  if RUNstatus.get() == 0:
18813 #
18814 def onCanvasBodeLeftClick(event):
18815  global X0LBP # Left top X value
18816  global Y0TBP # Left top Y value
18817  global GRWBP # Screenwidth
18818  global GRHBP # Screenheight
18819  global FontSize
18820  global Bodeca, MarkerLoc, SAMPLErate
18821  global COLORgrid, COLORtext, HScaleBP, ShowCA_VdB, ShowCB_VdB, DBdivindexBP
18822  global COLORtrace1, COLORtrace2, COLORtrace6, StartBodeEntry, StopBodeEntry, DBlevelBP
18823  global AWGSAMPLErate, RUNstatus, COLORtext, MarkerFreqNum, PrevdBV, PrevF, Vdiv
18824 
18825  if (RUNstatus.get() == 0):
18826  MarkerFreqNum = MarkerFreqNum + 1
18827  COLORmarker = COLORtrace6 # COLORgrid
18828  if ShowCA_VdB.get() == 1:
18829  COLORmarker = COLORtrace1
18830  elif ShowCB_VdB.get() == 1:
18831  COLORmarker = COLORtrace2
18832  try:
18833  EndFreq = float(StopBodeEntry.get())
18834  except:
18835  StopBodeEntry.delete(0,"end")
18836  StopBodeEntry.insert(0,10000)
18837  EndFreq = 10000
18838  try:
18839  BeginFreq = float(StartBodeEntry.get())
18840  except:
18841  StartBodeEntry.delete(0,"end")
18842  StartBodeEntry.insert(0,100)
18843  BeginFreq = 100
18844  # draw X at marker point and number
18845  Bodeca.create_line(event.x-4, event.y-4,event.x+4, event.y+5, fill=COLORmarker)
18846  Bodeca.create_line(event.x+4, event.y-4,event.x-4, event.y+5, fill=COLORmarker)
18847  Bodeca.create_text(event.x+4, event.y, text=str(MarkerFreqNum), fill=COLORmarker, anchor="w", font=("arial", FontSize ))
18848  # Vertical conversion factors (level dBs) and border limits
18849  Yconv = float(GRHBP) / (Vdiv.get() * DBdivlist[DBdivindexBP.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
18850  Yc = float(Y0TBP) + Yconv * (DBlevelBP.get()) # Yc is the 0 dBm position, can be outside the screen!
18851  Yphconv = float(GRHBP) / 360
18852  Yp = float(Y0TBP) + Yphconv + 180
18853  x1 = X0LBP + 14
18854  x2 = x1 + GRWBP
18855  # Horizontal conversion factors (frequency Hz) and border limits
18856  if HScaleBP.get() == 1:
18857  LogFStop = math.log10(EndFreq)
18858  try:
18859  LogFStart = math.log10(BeginFreq)
18860  except:
18861  LogFStart = 0.0
18862  LogFpixel = (LogFStop - LogFStart) / GRWBP
18863  xfreq = 10**(((event.x-x1)*LogFpixel) + LogFStart)
18864  else:
18865  Fpixel = (EndFreq - BeginFreq) / GRWBP # Frequency step per screen pixel
18866  xfreq = ((event.x-x1)*Fpixel)+BeginFreq
18867 
18868  yvdB = ((Yc-event.y)/Yconv)
18869  VdBString = ' {0:.1f} '.format(yvdB)
18870  XFString = ' {0:.2f} '.format(xfreq)
18871  V_label = str(MarkerFreqNum) + " " + XFString + " Hz, " + VdBString + " dBV"
18872  if MarkerFreqNum > 1:
18873  DeltaV = ' {0:.3f} '.format(yvdB-PrevdBV)
18874  DeltaF = ' {0:.2f} '.format(xfreq-PrevF)
18875  V_label = V_label + " Delta " + DeltaF + " Hz, " + DeltaV + " dBV"
18876  x = x1 + 5
18877  y = Y0TBP + 3 + (MarkerFreqNum*10)
18878  Justify = 'w'
18879  if MarkerLoc == 'UR' or MarkerLoc == 'ur':
18880  x = x2 - 5
18881  y = Y0TBP + 3 + (MarkerFreqNum*10)
18882  Justify = 'e'
18883  if MarkerLoc == 'LL' or MarkerLoc == 'll':
18884  x = x1 + 5
18885  y = Y0TBP + GRHBP + 3 - (MarkerFreqNum*10)
18886  Justify = 'w'
18887  if MarkerLoc == 'LR' or MarkerLoc == 'lr':
18888  x = x2 - 5
18889  y = Y0TBP + GRHBP + 3 - (MarkerFreqNum*10)
18890  Justify = 'e'
18891  Bodeca.create_text(x, y, text=V_label, fill=COLORmarker, anchor=Justify, font=("arial", FontSize ))
18892  PrevdBV = yvdB
18893  PrevF = xfreq
18894 #
18895 def onCanvasBdOne(event):
18896  global ShowCA_VdB
18897  if ShowCA_VdB.get() == 0:
18898  ShowCA_VdB.set(1)
18899  else:
18900  ShowCA_VdB.set(0)
18901 #
18902 def onCanvasBdTwo(event):
18903  global ShowCB_VdB
18904  if ShowCB_VdB.get() == 0:
18905  ShowCB_VdB.set(1)
18906  else:
18907  ShowCB_VdB.set(0)
18908 #
18909 def onCanvasBdThree(event):
18910  global ShowCA_P
18911  if ShowCA_P.get() == 0:
18912  ShowCA_P.set(1)
18913  else:
18914  ShowCA_P.set(0)
18915 #
18916 def onCanvasBdFour(event):
18917  global ShowCB_P
18918  if ShowCB_P.get() == 0:
18919  ShowCB_P.set(1)
18920  else:
18921  ShowCB_P.set(0)
18922 #
18923 def onCanvasBdFive(event):
18924  global ShowMarkerBP
18925  if ShowMarkerBP.get() == 0:
18926  ShowMarkerBP.set(1)
18927  else:
18928  ShowMarkerBP.set(0)
18929 #
18930 def onCanvasBdSix(event):
18931  global ShowRA_VdB
18932  if ShowRA_VdB.get() == 0:
18933  ShowRA_VdB.set(1)
18934  else:
18935  ShowRA_VdB.set(0)
18936 #
18937 def onCanvasBdSeven(event):
18938  global ShowRB_VdB
18939  if ShowRB_VdB.get() == 0:
18940  ShowRB_VdB.set(1)
18941  else:
18942  ShowRB_VdB.set(0)
18943 #
18944 def onCanvasBdEight(event):
18945  global ShowMathBP
18946  ShowMathBP.set(2)
18947 #
18948 def onCanvasBdNine(event):
18949  global ShowMathBP
18950  ShowMathBP.set(1)
18951 #
18952 def onCanvasBdZero(event):
18953  global ShowMathBP
18954  ShowMathBP.set(0)
18955 #
18956 def onCanvasBdSnap(event):
18957  BSTOREtraceBP()
18958 #
18959 def onCanvasShowBPcur(event):
18960  global ShowBPCur
18961  if ShowBPCur.get() == 0:
18962  ShowBPCur.set(1)
18963  else:
18964  ShowBPCur.set(0)
18965 #
18966 def onCanvasShowBdBcur(event):
18967  global ShowBdBCur
18968  if ShowBdBCur.get() == 1:
18969  ShowBdBCur.set(0)
18970  else:
18971  ShowBdBCur.set(1)
18972 #
18973 def onCanvasShowPdBcur(event):
18974  global ShowBdBCur
18975  if ShowBdBCur.get() == 2:
18976  ShowBdBCur.set(0)
18977  else:
18978  ShowBdBCur.set(2)
18979 #
18980 def onAWGAscroll(event):
18981  global AWGAShape
18982 
18983  onTextScroll(event)
18984  time.sleep(0.05)
18985  ReMakeAWGwaves()
18986  time.sleep(0.05)
18987 #
18988 def onAWGBscroll(event):
18989  global AWGBShape
18990 
18991  onTextScroll(event)
18992  time.sleep(0.05)
18993  ReMakeAWGwaves()
18994  time.sleep(0.05)
18995 #
18996 def onTextScroll(event): # Use mouse wheel to scroll entry values, august 7
18997  button = event.widget
18998  cursor_position = button.index(INSERT) # get current cursor position
18999  Pos = cursor_position
19000  OldVal = button.get() # get current entry string
19001  OldValfl = float(OldVal) # and its value
19002  NewVal = OldValfl
19003  Len = len(OldVal)
19004  Dot = OldVal.find (".") # find decimal point position
19005  Decimals = Len - Dot - 1
19006  if Dot == -1 : # no point
19007  Decimals = 0
19008  Step = 10**(Len - Pos)
19009  elif Pos <= Dot : # no point left of position
19010  Step = 10**(Dot - Pos)
19011  else:
19012  Step = 10**(Dot - Pos + 1)
19013  # respond to Linux or Windows wheel event
19014  if event.num == 5 or event.delta == -120:
19015  NewVal = OldValfl - Step
19016  if event.num == 4 or event.delta == 120:
19017  NewVal = OldValfl + Step
19018  FormatStr = "{0:." + str(Decimals) + "f}"
19019  NewStr = FormatStr.format(NewVal)
19020  NewDot = NewStr.find (".")
19021  NewPos = Pos + NewDot - Dot
19022  if Decimals == 0 :
19023  NewLen = len(NewStr)
19024  NewPos = Pos + NewLen - Len
19025  button.delete(0, END) # remove old entry
19026  button.insert(0, NewStr) # insert new entry
19027  button.icursor(NewPos) # resets the insertion cursor
19028 #
19029 def onAWGAkey(event):
19030  global AWGAShape
19031 
19032  onTextKey(event)
19033  ReMakeAWGwaves()
19034 #
19035 def onAWGBkey(event):
19036  global AWGBShape
19037 
19038  onTextKey(event)
19039  ReMakeAWGwaves()
19040 #
19041 def onTextKeyAWG(event):
19042  onTextKey(event)
19043  ReMakeAWGwaves()
19044 #
19045 # Use Arriw keys to inc dec entry values
19046 def onTextKey(event):
19047  button = event.widget
19048  cursor_position = button.index(INSERT) # get current cursor position
19049  Pos = cursor_position
19050  OldVal = button.get() # get current entry string
19051  OldValfl = float(OldVal) # and its value
19052  Len = len(OldVal)
19053  Dot = OldVal.find (".") # find decimal point position
19054  Decimals = Len - Dot - 1
19055  if Dot == -1 : # no point
19056  Decimals = 0
19057  Step = 10**(Len - Pos)
19058  elif Pos <= Dot : # no point left of position
19059  Step = 10**(Dot - Pos)
19060  else:
19061  Step = 10**(Dot - Pos + 1)
19062  if platform.system() == "Windows":
19063  if event.keycode == 38: # increment digit for up arrow key
19064  NewVal = OldValfl + Step
19065  elif event.keycode == 40: # decrement digit for down arrow
19066  NewVal = OldValfl - Step
19067  else:
19068  return
19069  elif platform.system() == "Linux":
19070  if event.keycode == 111: # increment digit for up arrow key
19071  NewVal = OldValfl + Step
19072  elif event.keycode == 116: # decrement digit for down arrow
19073  NewVal = OldValfl - Step
19074  else:
19075  return
19076  elif platform.system() == "Darwin":
19077  if event.keycode == 0x7D: # increment digit for up arrow key
19078  NewVal = OldValfl + Step
19079  elif event.keycode == 0x7E: # decrement digit for down arrow
19080  NewVal = OldValfl - Step
19081  else:
19082  return
19083  else:
19084  return
19085 #
19086  FormatStr = "{0:." + str(Decimals) + "f}"
19087  NewStr = FormatStr.format(NewVal)
19088  NewDot = NewStr.find (".")
19089  NewPos = Pos + NewDot - Dot
19090  if Decimals == 0 :
19091  NewLen = len(NewStr)
19092  NewPos = Pos + NewLen - Len
19093  button.delete(0, END) # remove old entry
19094  button.insert(0, NewStr) # insert new entry
19095  button.icursor(NewPos) # resets the insertion cursor
19096 #
19097 #
19098 def onSpinBoxScroll(event):
19099  spbox = event.widget
19100  if sys.version_info[0] == 3 and sys.version_info[1] > 6: # Spin Boxes do this automatically in Python > 3.6 apparently
19101  return
19102  if event.num == 4 or event.delta > 0: # if event.delta > 0: # increment digit
19103  spbox.invoke('buttonup')
19104  if event.num == 5 or event.delta < 0:
19105  spbox.invoke('buttondown')
19106 #
19107 # ================ Make awg sub window ==========================
19108 def MakeAWGWindow():
19109  global AWGAMode, AWGATerm, AWGAShape, AWGSync, awgwindow, AWGAPhaseDelay, AWGBPhaseDelay
19110  global AWGBMode, AWGBTerm, AWGBShape, AWGScreenStatus, AWGARepeatFlag, AWGBRepeatFlag
19111  global AWGABurstFlag, AWGBBurstFlag, AWGAShapeLabel, AWGBShapeLabel, AWGShowAdvanced
19112  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGAPhaseEntry, AWGADutyCycleEntry
19113  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBPhaseEntry, AWGBDutyCycleEntry
19114  global AWGALength, AWGBLength, RevDate, phasealab, phaseblab, AWGAModeLabel, AWGBModeLabel
19115  global AWGAIOMode, AWGBIOMode, duty1lab, duty2lab, awgaph, awgadel, awgbph, awgbdel
19116  global AwgLayout, AWG_Amp_Mode, awgsync, SWRev # 0 = Min/Max mode, 1 = Amp/Offset
19117  global amp1lab, amp2lab, off1lab, off2lab, Reset_Freq, AWG_2X, BisCompA, FWRevOne
19118  global ModeAMenu, ShapeAMenu, amp1lab, off1lab, freq1lab, awgaph, awgadel, ModeBMenu, ShapeBMenu
19119  global amp2lab, off2lab, freq2lab, awgbph, awgbdel, bcompa, awgsync, LockFreq
19120  global AWGANoiseEntry, AWGBNoiseEntry, AWGAsbnoise, AWGBsbnoise, NoiseList
19121 
19122  if AWGScreenStatus.get() == 0:
19123  AWGScreenStatus.set(1)
19124 
19125  awgwindow = Toplevel()
19126  awgwindow.title("AWG Controls " + SWRev + RevDate)
19127  awgwindow.resizable(FALSE,FALSE)
19128  awgwindow.geometry('+0+100')
19129  awgwindow.protocol("WM_DELETE_WINDOW", DestroyAWGScreen)
19130  #
19131  frame2 = LabelFrame(awgwindow, text="AWG CH A", style="A10R1.TLabelframe")
19132  frame3 = LabelFrame(awgwindow, text="AWG CH B", style="A10R2.TLabelframe")
19133  #
19134  if AwgLayout == "Horz":
19135  frame2.pack(side=LEFT, expand=1, fill=X)
19136  frame3.pack(side=LEFT, expand=1, fill=X)
19137  else:
19138  frame2.pack(side=TOP, expand=1, fill=Y)
19139  frame3.pack(side=TOP, expand=1, fill=Y)
19140  # now AWG A
19141  # AWG enable sub frame
19142  awg1eb = Frame( frame2 )
19143  awg1eb.pack(side=TOP)
19144  ModeAMenu = Menubutton(awg1eb, text="Mode", style="W5.TButton")
19145  ModeAMenu.menu = Menu(ModeAMenu, tearoff = 0 )
19146  ModeAMenu["menu"] = ModeAMenu.menu
19147  ModeAMenu.menu.add_command(label="-Mode-", foreground="blue", command=donothing)
19148  ModeAMenu.menu.add_radiobutton(label="SVMI", variable=AWGAMode, value=0, command=BAWGAModeLabel)
19149  ModeAMenu.menu.add_radiobutton(label="SIMV", variable=AWGAMode, value=1, command=BAWGAModeLabel)
19150  ModeAMenu.menu.add_radiobutton(label="Hi-Z", variable=AWGAMode, value=2, command=BAWGAModeLabel)
19151  ModeAMenu.menu.add_checkbutton(label="Split I/O", variable=AWGAIOMode, command=BAWGAModeLabel)
19152  ModeAMenu.menu.add_separator()
19153  ModeAMenu.menu.add_command(label="-Term-", foreground="blue", command=donothing)
19154  ModeAMenu.menu.add_radiobutton(label="Open", variable=AWGATerm, value=0, command=UpdateAwgCont)
19155  ModeAMenu.menu.add_radiobutton(label="To GND", variable=AWGATerm, value=1, command=UpdateAwgCont)
19156  ModeAMenu.menu.add_radiobutton(label="To 2.5V", variable=AWGATerm, value=2, command=UpdateAwgCont)
19157  ModeAMenu.pack(side=LEFT, anchor=W)
19158  ShapeAMenu = Menubutton(awg1eb, text="Shape", style="W6.TButton")
19159  ShapeAMenu.menu = Menu(ShapeAMenu, tearoff = 0 )
19160  ShapeAMenu["menu"] = ShapeAMenu.menu
19161  ShapeAMenu.menu.add_command(label="-Basic-", foreground="blue", command=donothing)
19162  ShapeAMenu.menu.add_radiobutton(label="DC", variable=AWGAShape, value=0, command=ReMakeAWGwaves)
19163  ShapeAMenu.menu.add_radiobutton(label="Sine", variable=AWGAShape, value=18, command=ReMakeAWGwaves)
19164  ShapeAMenu.menu.add_radiobutton(label="Triangle", variable=AWGAShape, value=2, command=ReMakeAWGwaves)
19165  ShapeAMenu.menu.add_radiobutton(label="Sawtooth", variable=AWGAShape, value=3, command=ReMakeAWGwaves)
19166  ShapeAMenu.menu.add_radiobutton(label="Square", variable=AWGAShape, value=4, command=ReMakeAWGwaves)
19167  ShapeAMenu.menu.add_radiobutton(label="StairStep", variable=AWGAShape, value=5, command=ReMakeAWGwaves)
19168  if AWGShowAdvanced.get() > 0:
19169  ShapeAMenu.menu.add_command(label="-Advanced-", foreground="blue", command=donothing)
19170  ShapeAMenu.menu.add_radiobutton(label="Impulse", variable=AWGAShape, value=9, command=ReMakeAWGwaves)
19171  ShapeAMenu.menu.add_radiobutton(label="Trapezoid", variable=AWGAShape, value=11, command=ReMakeAWGwaves)
19172  ShapeAMenu.menu.add_radiobutton(label="Pulse", variable=AWGAShape, value=20, command=ReMakeAWGwaves)
19173  ShapeAMenu.menu.add_radiobutton(label="Ramp", variable=AWGAShape, value=16, command=ReMakeAWGwaves)
19174  ShapeAMenu.menu.add_radiobutton(label="SSQ Pulse", variable=AWGAShape, value=15, command=ReMakeAWGwaves)
19175  ShapeAMenu.menu.add_radiobutton(label="U-D Ramp", variable=AWGAShape, value=12, command=ReMakeAWGwaves)
19176  ShapeAMenu.menu.add_radiobutton(label="Fourier Series", variable=AWGAShape, value=14, command=AWGAMakeFourier)
19177  ShapeAMenu.menu.add_radiobutton(label="Sin X/X", variable=AWGAShape, value=19, command=ReMakeAWGwaves)
19178  ShapeAMenu.menu.add_radiobutton(label="PWM Sine", variable=AWGAShape, value=17, command=ReMakeAWGwaves)
19179  ShapeAMenu.menu.add_radiobutton(label="FM Sine", variable=AWGAShape, value=21, command=AWGAMakeFMSine)
19180  ShapeAMenu.menu.add_radiobutton(label="AM Sine", variable=AWGAShape, value=22, command=AWGAMakeAMSine)
19181  ShapeAMenu.menu.add_radiobutton(label="Full Wave", variable=AWGAShape, value=23, command=ReMakeAWGwaves)
19182  ShapeAMenu.menu.add_radiobutton(label="Half Wave", variable=AWGAShape, value=24, command=ReMakeAWGwaves)
19183  # These stand alone shapes are now redundant, use add noise to 0 amplt sine
19184  # ShapeAMenu.menu.add_radiobutton(label="UU Noise", variable=AWGAShape, value=7, command=ReMakeAWGwaves)
19185  # ShapeAMenu.menu.add_radiobutton(label="UG Noise", variable=AWGAShape, value=8, command=ReMakeAWGwaves)
19186  else:
19187  ShapeAMenu.menu.add_separator()
19188  ShapeAMenu.menu.add_radiobutton(label="Math", variable=AWGAShape, value=10, command=AWGAMakeMath)
19189  ShapeAMenu.menu.add_radiobutton(label="Read CSV File", variable=AWGAShape, value=6, command=AWGAReadFile)
19190  ShapeAMenu.menu.add_radiobutton(label="Read WAV File", variable=AWGAShape, value=13, command=AWGAReadWAV)
19191  ShapeAMenu.menu.add_command(label="Save CSV File", command=AWGAWriteFile)
19192  ShapeAMenu.menu.add_checkbutton(label='Burst', variable=AWGABurstFlag, command=AWGANumCycles)
19193  ShapeAMenu.menu.add_checkbutton(label='Repeat', variable=AWGARepeatFlag)
19194  ShapeAMenu.pack(side=LEFT, anchor=W)
19195  #
19196  AWGAModeLabel = Label(frame2, text="AWG A Mode")
19197  AWGAModeLabel.pack(side=TOP)
19198  AWGAShapeLabel = Label(frame2, text="AWG A Shape")
19199  AWGAShapeLabel.pack(side=TOP)
19200  #
19201  awg1ampl = Frame( frame2 )
19202  awg1ampl.pack(side=TOP)
19203  AWGAAmplEntry = Entry(awg1ampl, width=5, cursor='double_arrow')
19204  AWGAAmplEntry.bind("<Return>", UpdateAwgContRet)
19205  AWGAAmplEntry.bind('<MouseWheel>', onAWGAscroll)
19206  AWGAAmplEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
19207  AWGAAmplEntry.bind("<Button-5>", onAWGAscroll)
19208  AWGAAmplEntry.bind('<Key>', onTextKeyAWG)
19209  AWGAAmplEntry.pack(side=LEFT, anchor=W)
19210  AWGAAmplEntry.delete(0,"end")
19211  AWGAAmplEntry.insert(0,0.0)
19212  amp1lab = Label(awg1ampl) #, text="Min Ch A")
19213  amp1lab.pack(side=LEFT, anchor=W)
19214  #
19215  awg1off = Frame( frame2 )
19216  awg1off.pack(side=TOP)
19217  AWGAOffsetEntry = Entry(awg1off, width=5, cursor='double_arrow')
19218  AWGAOffsetEntry.bind("<Return>", UpdateAwgContRet)
19219  AWGAOffsetEntry.bind('<MouseWheel>', onAWGAscroll)
19220  AWGAOffsetEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
19221  AWGAOffsetEntry.bind("<Button-5>", onAWGAscroll)
19222  AWGAOffsetEntry.bind('<Key>', onTextKeyAWG)
19223  AWGAOffsetEntry.pack(side=LEFT, anchor=W)
19224  AWGAOffsetEntry.delete(0,"end")
19225  AWGAOffsetEntry.insert(0,0.0)
19226  off1lab = Label(awg1off) #, text="Max Ch A")
19227  off1lab.pack(side=LEFT, anchor=W)
19228  if AWG_Amp_Mode.get() == 0:
19229  amp1lab.config(text = "Min Ch A" ) # change displayed value
19230  off1lab.config(text = "Max Ch A" ) # change displayed value
19231  else:
19232  amp1lab.config(text = "Amp Ch A" )
19233  off1lab.config(text = "Off Ch A" )
19234  # AWG Frequency sub frame
19235  awg1freq = Frame( frame2 )
19236  awg1freq.pack(side=TOP)
19237  AWGAFreqEntry = Entry(awg1freq, width=7, cursor='double_arrow')
19238  AWGAFreqEntry.bind("<Return>", UpdateAwgContRet)
19239  AWGAFreqEntry.bind('<MouseWheel>', onAWGAscroll)
19240  AWGAFreqEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
19241  AWGAFreqEntry.bind("<Button-5>", onAWGAscroll)
19242  AWGAFreqEntry.bind('<Key>', onTextKeyAWG)
19243  AWGAFreqEntry.pack(side=LEFT, anchor=W)
19244  AWGAFreqEntry.delete(0,"end")
19245  AWGAFreqEntry.insert(0,100.0)
19246  freq1lab = Label(awg1freq, text="Freq Ch A")
19247  freq1lab.pack(side=LEFT, anchor=W)
19248  # AWG Phase or delay select sub frame
19249  # AWG Phase entry sub frame
19250  awg1phase = Frame( frame2 )
19251  awg1phase.pack(side=TOP)
19252  awgaph = Button(awg1phase, text="Phase", style="W5.TButton", command=ToggleAWGAPhaseDelay)
19253  awgaph.pack(side=LEFT, anchor=W)
19254  AWGAPhaseEntry = Entry(awg1phase, width=4, cursor='double_arrow')
19255  AWGAPhaseEntry.bind("<Return>", UpdateAwgContRet)
19256  AWGAPhaseEntry.bind('<MouseWheel>', onAWGAscroll)
19257  AWGAPhaseEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
19258  AWGAPhaseEntry.bind("<Button-5>", onAWGAscroll)
19259  AWGAPhaseEntry.bind('<Key>', onTextKeyAWG)
19260  AWGAPhaseEntry.pack(side=LEFT, anchor=W)
19261  AWGAPhaseEntry.delete(0,"end")
19262  AWGAPhaseEntry.insert(0,0)
19263  phasealab = Label(awg1phase, text="Deg")
19264  phasealab.pack(side=LEFT, anchor=W)
19265  # AWG duty cycle frame
19266  awg1dc = Frame( frame2 )
19267  awg1dc.pack(side=TOP)
19268  AWGADutyCycleEntry = Entry(awg1dc, width=5, cursor='double_arrow')
19269  AWGADutyCycleEntry.bind("<Return>", UpdateAwgContRet)
19270  AWGADutyCycleEntry.bind('<MouseWheel>', onAWGAscroll)
19271  AWGADutyCycleEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
19272  AWGADutyCycleEntry.bind("<Button-5>", onAWGAscroll)
19273  AWGADutyCycleEntry.bind('<Key>', onTextKeyAWG)
19274  AWGADutyCycleEntry.pack(side=LEFT, anchor=W)
19275  AWGADutyCycleEntry.delete(0,"end")
19276  AWGADutyCycleEntry.insert(0,50)
19277  duty1lab = Label(awg1dc, text="%")
19278  duty1lab.pack(side=LEFT, anchor=W)
19279  #
19280  AWGALength = Label(frame2, text="Length")
19281  AWGALength.pack(side=TOP)
19282  # Noise Controls
19283  anoise = Frame( frame2 )
19284  anoise.pack(side=TOP)
19285  AWGANoise = Label(anoise, text="Noise")
19286  AWGANoise.pack(side=LEFT, anchor=W)
19287  AWGAsbnoise = Spinbox(anoise, width=8, cursor='double_arrow', values=NoiseList, command=ReMakeAWGwaves)
19288  AWGAsbnoise.bind('<MouseWheel>', onSpinBoxScroll)
19289  AWGAsbnoise.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
19290  AWGAsbnoise.bind("<Button-5>", onSpinBoxScroll)
19291  AWGAsbnoise.pack(side=LEFT, anchor=W)
19292  AWGANoiseEntry = Entry(anoise, width=5, cursor='double_arrow')
19293  AWGANoiseEntry.bind("<Return>", UpdateAwgContRet)
19294  AWGANoiseEntry.bind('<MouseWheel>', onAWGAscroll)
19295  AWGANoiseEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
19296  AWGANoiseEntry.bind("<Button-5>", onAWGAscroll)
19297  AWGANoiseEntry.bind('<Key>', onTextKeyAWG)
19298  AWGANoiseEntry.pack(side=LEFT, anchor=W)
19299  AWGANoiseEntry.delete(0,"end")
19300  AWGANoiseEntry.insert(0,0.0)
19301  #
19302  freqlock = Checkbutton(frame2, text="Lock Freq", variable=LockFreq) # , command=)
19303  freqlock.pack(side=TOP)
19304  if FWRevOne > 2.16:
19305  awg2x1 = Radiobutton(frame2, text="Both CH 1X", variable=AWG_2X, value=0, command=BAWG2X)
19306  awg2x1.pack(side=TOP)
19307  axg2xf = Frame( frame2 )
19308  axg2xf.pack(side=TOP)
19309  awg2x2 = Radiobutton(axg2xf, text="CH A 2X", variable=AWG_2X, value=1, command=BAWG2X)
19310  awg2x2.pack(side=LEFT, anchor=W)
19311  awg2x3 = Radiobutton(axg2xf, text="CH B 2X", variable=AWG_2X, value=2, command=BAWG2X)
19312  awg2x3.pack(side=LEFT, anchor=W)
19313  else:
19314  awgsync = Checkbutton(frame2, text="Sync AWG", variable=AWGSync, command=BAWGSync)
19315  awgsync.pack(side=TOP)
19316  # now AWG B
19317  # AWG enable sub frame
19318  awg2eb = Frame( frame3 )
19319  awg2eb.pack(side=TOP)
19320  ModeBMenu = Menubutton(awg2eb, text="Mode", style="W5.TButton")
19321  ModeBMenu.menu = Menu(ModeBMenu, tearoff = 0 )
19322  ModeBMenu["menu"] = ModeBMenu.menu
19323  ModeBMenu.menu.add_command(label="-Mode-", foreground="blue", command=donothing)
19324  ModeBMenu.menu.add_radiobutton(label="SVMI", variable=AWGBMode, value=0, command=BAWGBModeLabel)
19325  ModeBMenu.menu.add_radiobutton(label="SIMV", variable=AWGBMode, value=1, command=BAWGBModeLabel)
19326  ModeBMenu.menu.add_radiobutton(label="Hi-Z", variable=AWGBMode, value=2, command=BAWGBModeLabel)
19327  ModeBMenu.menu.add_checkbutton(label="Split I/O", variable=AWGBIOMode, command=BAWGBModeLabel)
19328  ModeBMenu.menu.add_separator()
19329  ModeBMenu.menu.add_command(label="-Term-", foreground="blue", command=donothing)
19330  ModeBMenu.menu.add_radiobutton(label="Open", variable=AWGBTerm, value=0, command=UpdateAwgCont)
19331  ModeBMenu.menu.add_radiobutton(label="To GND", variable=AWGBTerm, value=1, command=UpdateAwgCont)
19332  ModeBMenu.menu.add_radiobutton(label="To 2.5V", variable=AWGBTerm, value=2, command=UpdateAwgCont)
19333  ModeBMenu.pack(side=LEFT, anchor=W)
19334  ShapeBMenu = Menubutton(awg2eb, text="Shape", style="W6.TButton")
19335  ShapeBMenu.menu = Menu(ShapeBMenu, tearoff = 0 )
19336  ShapeBMenu["menu"] = ShapeBMenu.menu
19337  ShapeBMenu.menu.add_command(label="-Basic-", foreground="blue", command=donothing)
19338  ShapeBMenu.menu.add_radiobutton(label="DC", variable=AWGBShape, value=0, command=ReMakeAWGwaves)
19339  ShapeBMenu.menu.add_radiobutton(label="Sine", variable=AWGBShape, value=18, command=ReMakeAWGwaves)
19340  ShapeBMenu.menu.add_radiobutton(label="Triangle", variable=AWGBShape, value=2, command=ReMakeAWGwaves)
19341  ShapeBMenu.menu.add_radiobutton(label="Sawtooth", variable=AWGBShape, value=3, command=ReMakeAWGwaves)
19342  ShapeBMenu.menu.add_radiobutton(label="Square", variable=AWGBShape, value=4, command=ReMakeAWGwaves)
19343  ShapeBMenu.menu.add_radiobutton(label="StairStep", variable=AWGBShape, value=5, command=ReMakeAWGwaves)
19344  if AWGShowAdvanced.get() > 0:
19345  ShapeBMenu.menu.add_command(label="-Advanced-", foreground="blue", command=donothing)
19346  ShapeBMenu.menu.add_radiobutton(label="Impulse", variable=AWGBShape, value=9, command=ReMakeAWGwaves)
19347  ShapeBMenu.menu.add_radiobutton(label="Trapezoid", variable=AWGBShape, value=11, command=ReMakeAWGwaves)
19348  ShapeBMenu.menu.add_radiobutton(label="Pulse", variable=AWGBShape, value=20, command=ReMakeAWGwaves)
19349  ShapeBMenu.menu.add_radiobutton(label="Ramp", variable=AWGBShape, value=16, command=ReMakeAWGwaves)
19350  ShapeBMenu.menu.add_radiobutton(label="SSQ Pulse", variable=AWGBShape, value=15, command=ReMakeAWGwaves)
19351  ShapeBMenu.menu.add_radiobutton(label="U-D Ramp", variable=AWGBShape, value=12, command=ReMakeAWGwaves)
19352  ShapeBMenu.menu.add_radiobutton(label="Fourier Series", variable=AWGBShape, value=14, command=AWGBMakeFourier)
19353  ShapeBMenu.menu.add_radiobutton(label="Sin X/X", variable=AWGBShape, value=19, command=ReMakeAWGwaves)
19354  ShapeBMenu.menu.add_radiobutton(label="PWM Sine", variable=AWGBShape, value=17, command=ReMakeAWGwaves)
19355  ShapeBMenu.menu.add_radiobutton(label="Full Wave", variable=AWGBShape, value=23, command=ReMakeAWGwaves)
19356  ShapeBMenu.menu.add_radiobutton(label="Half Wave", variable=AWGBShape, value=24, command=ReMakeAWGwaves)
19357  # These stand alone shapes are now redundant, use add noise to 0 amplt sine
19358  # ShapeBMenu.menu.add_radiobutton(label="UU Noise", variable=AWGBShape, value=7, command=ReMakeAWGwaves)
19359  # ShapeBMenu.menu.add_radiobutton(label="UG Noise", variable=AWGBShape, value=8, command=ReMakeAWGwaves)
19360  else:
19361  ShapeBMenu.menu.add_separator()
19362  ShapeBMenu.menu.add_radiobutton(label="Math", variable=AWGBShape, value=10, command=AWGBMakeMath)
19363  ShapeBMenu.menu.add_radiobutton(label="Read CSV File", variable=AWGBShape, value=6, command=AWGBReadFile)
19364  ShapeBMenu.menu.add_radiobutton(label="Read WAV File", variable=AWGBShape, value=13, command=AWGBReadWAV)
19365  ShapeBMenu.menu.add_command(label="Save CSV File", command=AWGBWriteFile)
19366  ShapeBMenu.menu.add_checkbutton(label='Burst', variable=AWGBBurstFlag, command=AWGBNumCycles)
19367  ShapeBMenu.menu.add_checkbutton(label='Repeat', variable=AWGBRepeatFlag)
19368  ShapeBMenu.pack(side=LEFT, anchor=W)
19369  #
19370  AWGBModeLabel = Label(frame3, text="AWG B Mode")
19371  AWGBModeLabel.pack(side=TOP)
19372  AWGBShapeLabel = Label(frame3, text="AWG B Shape")
19373  AWGBShapeLabel.pack(side=TOP)
19374  #
19375  awg2ampl = Frame( frame3 )
19376  awg2ampl.pack(side=TOP)
19377  AWGBAmplEntry = Entry(awg2ampl, width=5, cursor='double_arrow')
19378  AWGBAmplEntry.bind("<Return>", UpdateAwgContRet)
19379  AWGBAmplEntry.bind('<MouseWheel>', onAWGBscroll)
19380  AWGBAmplEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
19381  AWGBAmplEntry.bind("<Button-5>", onAWGBscroll)
19382  AWGBAmplEntry.bind('<Key>', onTextKeyAWG)
19383  AWGBAmplEntry.pack(side=LEFT, anchor=W)
19384  AWGBAmplEntry.delete(0,"end")
19385  AWGBAmplEntry.insert(0,0.0)
19386  amp2lab = Label(awg2ampl) #, text="Min Ch B")
19387  amp2lab.pack(side=LEFT, anchor=W)
19388  #
19389  awg2off = Frame( frame3 )
19390  awg2off.pack(side=TOP)
19391  AWGBOffsetEntry = Entry(awg2off, width=5, cursor='double_arrow')
19392  AWGBOffsetEntry.bind("<Return>", UpdateAwgContRet)
19393  AWGBOffsetEntry.bind('<MouseWheel>', onAWGBscroll)
19394  AWGBOffsetEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
19395  AWGBOffsetEntry.bind("<Button-5>", onAWGBscroll)
19396  AWGBOffsetEntry.bind('<Key>', onTextKeyAWG)
19397  AWGBOffsetEntry.pack(side=LEFT, anchor=W)
19398  AWGBOffsetEntry.delete(0,"end")
19399  AWGBOffsetEntry.insert(0,0.0)
19400  off2lab = Label(awg2off) #, text="Max Ch B")
19401  off2lab.pack(side=LEFT, anchor=W)
19402  if AWG_Amp_Mode.get() == 0:
19403  amp2lab.config(text = "Min Ch B" ) # change displayed value
19404  off2lab.config(text = "Max Ch B" ) # change displayed value
19405  else:
19406  amp2lab.config(text = "Amp Ch B" )
19407  off2lab.config(text = "Off Ch B" )
19408  # AWG Frequency sub frame
19409  awg2freq = Frame( frame3 )
19410  awg2freq.pack(side=TOP)
19411  AWGBFreqEntry = Entry(awg2freq, width=7, cursor='double_arrow')
19412  AWGBFreqEntry.bind("<Return>", UpdateAwgContRet)
19413  AWGBFreqEntry.bind('<MouseWheel>', onAWGBscroll)
19414  AWGBFreqEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
19415  AWGBFreqEntry.bind("<Button-5>", onAWGBscroll)
19416  AWGBFreqEntry.bind('<Key>', onTextKeyAWG)
19417  AWGBFreqEntry.pack(side=LEFT, anchor=W)
19418  AWGBFreqEntry.delete(0,"end")
19419  AWGBFreqEntry.insert(0,100.0)
19420  freq2lab = Label(awg2freq, text="Freq Ch B")
19421  freq2lab.pack(side=LEFT, anchor=W)
19422  # AWG Phase or delay select sub frame
19423  # AWG Phase sub frame
19424  awg2phase = Frame( frame3 )
19425  awg2phase.pack(side=TOP)
19426  awgbph = Button(awg2phase, text="Phase", style="W5.TButton", command=ToggleAWGBPhaseDelay)
19427  awgbph.pack(side=LEFT, anchor=W)
19428  AWGBPhaseEntry = Entry(awg2phase, width=4, cursor='double_arrow')
19429  AWGBPhaseEntry.bind("<Return>", UpdateAwgContRet)
19430  AWGBPhaseEntry.bind('<MouseWheel>', onAWGBscroll)
19431  AWGBPhaseEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
19432  AWGBPhaseEntry.bind("<Button-5>", onAWGBscroll)
19433  AWGBPhaseEntry.bind('<Key>', onTextKeyAWG)
19434  AWGBPhaseEntry.pack(side=LEFT, anchor=W)
19435  AWGBPhaseEntry.delete(0,"end")
19436  AWGBPhaseEntry.insert(0,0)
19437  phaseblab = Label(awg2phase, text="Deg")
19438  phaseblab.pack(side=LEFT, anchor=W)
19439  # AWG duty cycle frame
19440  awg2dc = Frame( frame3 )
19441  awg2dc.pack(side=TOP)
19442  AWGBDutyCycleEntry = Entry(awg2dc, width=5, cursor='double_arrow')
19443  AWGBDutyCycleEntry.bind("<Return>", UpdateAwgContRet)
19444  AWGBDutyCycleEntry.bind('<MouseWheel>', onAWGBscroll)
19445  AWGBDutyCycleEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
19446  AWGBDutyCycleEntry.bind("<Button-5>", onAWGBscroll)
19447  AWGBDutyCycleEntry.bind('<Key>', onTextKeyAWG)
19448  AWGBDutyCycleEntry.pack(side=LEFT, anchor=W)
19449  AWGBDutyCycleEntry.delete(0,"end")
19450  AWGBDutyCycleEntry.insert(0,50)
19451  duty2lab = Label(awg2dc, text="%")
19452  duty2lab.pack(side=LEFT, anchor=W)
19453  #
19454  AWGBLength = Label(frame3, text="Length")
19455  AWGBLength.pack(side=TOP)
19456  # Noise Controls
19457  bnoise = Frame( frame3 )
19458  bnoise.pack(side=TOP)
19459  AWGBNoise = Label(bnoise, text="Noise")
19460  AWGBNoise.pack(side=LEFT, anchor=W)
19461  AWGBsbnoise = Spinbox(bnoise, width=8, cursor='double_arrow', values=NoiseList, command=ReMakeAWGwaves)
19462  AWGBsbnoise.bind('<MouseWheel>', onSpinBoxScroll)
19463  AWGBsbnoise.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
19464  AWGBsbnoise.bind("<Button-5>", onSpinBoxScroll)
19465  AWGBsbnoise.pack(side=LEFT, anchor=W)
19466  AWGBNoiseEntry = Entry(bnoise, width=5, cursor='double_arrow')
19467  AWGBNoiseEntry.bind("<Return>", UpdateAwgContRet)
19468  AWGBNoiseEntry.bind('<MouseWheel>', onAWGBscroll)
19469  AWGBNoiseEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
19470  AWGBNoiseEntry.bind("<Button-5>", onAWGBscroll)
19471  AWGBNoiseEntry.bind('<Key>', onTextKeyAWG)
19472  AWGBNoiseEntry.pack(side=LEFT, anchor=W)
19473  AWGBNoiseEntry.delete(0,"end")
19474  AWGBNoiseEntry.insert(0,0.0)
19475  #
19476  bcompa = Checkbutton(frame3, text="B = Comp A", variable=BisCompA, command=ReMakeAWGwaves)#SetBCompA)
19477  bcompa.pack(side=TOP)
19478  if FWRevOne > 2.16:
19479  awgsync = Checkbutton(frame3, text="Sync AWG", variable=AWGSync, command=BAWGSync)
19480  awgsync.pack(side=TOP)
19481  #
19482  dismissbutton = Button(frame3, text="Minimize", style="W8.TButton", command=DestroyAWGScreen)
19483  dismissbutton.pack(side=TOP)
19484  if ShowBallonHelp > 0:
19485  BuildAWGAPhase_tip = CreateToolTip(awgaph, 'Toggle between degrees and time')
19486  BuildAWGBPhase_tip = CreateToolTip(awgbph, 'Toggle between degrees and time')
19487  BuildAWGSync_tip = CreateToolTip(awgsync, 'Toggle between continuous and discontinuous modes')
19488  BuildBComp_tip = CreateToolTip(bcompa, 'Lock CH B to be the inverse of CH A')
19489  BuildModeAMenu_tip = CreateToolTip(ModeAMenu, 'Configure channel output mode')
19490  BuildModeBMenu_tip = CreateToolTip(ModeBMenu, 'Configure channel output mode')
19491  BuildShapeAMenu_tip = CreateToolTip(ShapeAMenu, 'Set channel waveform shape')
19492  BuildShapeBMenu_tip = CreateToolTip(ShapeBMenu, 'Set channel waveform shape')
19493  else:
19494  awgwindow.deiconify()
19495 #
19496 def BAWG2X():
19497  global AWG_2X, devx, AWGAIOMode, AWGBIOMode, BisCompA
19498 
19499  ReMakeAWGwaves()
19500  if AWG_2X.get() == 0: # configure board for both AWG channels at 1X sampling
19501  devx.ctrl_transfer(0x40, 0x24, 0x0, 0, 0, 0, 100) # set to addr DAC A
19502  devx.ctrl_transfer(0x40, 0x25, 0x1, 0, 0, 0, 100) # set to addr DAC B
19503  elif AWG_2X.get() == 1: # configure board for single AWG channel A at 2X sampling
19504  devx.ctrl_transfer(0x40, 0x24, 0x0, 0, 0, 0, 100) # set to addr DAC A
19505  devx.ctrl_transfer(0x40, 0x25, 0x0, 0, 0, 0, 100) # set t0 addr DAC A
19506  if AWGBIOMode.get() == 0: # if channel b is not in split I/O mode turn off output
19507  devx.ctrl_transfer(0x40, 0x51, 40, 0, 0, 0, 100) # set IN3 switch to open
19508  devx.ctrl_transfer(0x40, 0x51, 52, 0, 0, 0, 100) # set IN3 switch to open
19509  BisCompA.set(0)
19510  elif AWG_2X.get() == 2: # configure board for single AWG channel B at 2X sampling
19511  devx.ctrl_transfer(0x40, 0x24, 0x1, 0, 0, 0, 100) # set to addr DAC B
19512  devx.ctrl_transfer(0x40, 0x25, 0x1, 0, 0, 0, 100) # set to addr DAC B
19513  if AWGAIOMode.get() == 0: # if channel a is not in split I/O mode turn off output
19514  devx.ctrl_transfer(0x40, 0x51, 35, 0, 0, 0, 100) # set IN3 switch to open
19515  devx.ctrl_transfer(0x40, 0x51, 51, 0, 0, 0, 100) # set IN3 switch to open
19516  BisCompA.set(0)
19517 #
19518 def DestroyAWGScreen():
19519  global awgwindow, AWGScreenStatus
19520 
19521  # AWGScreenStatus.set(0)
19522  awgwindow.iconify()
19523 #
19524 # ===== Channel B Mux Mode sub Window =======
19525 def MakeMuxModeWindow():
19526  global MuxScreenStatus, muxwindow, RevDate, DacScreenStatus, DigScreenStatus
19527  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry
19528  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry, SyncButton
19529  global CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab, CHBlab, CHBofflab
19530  global CHB_cba, CHB_cbb, CHB_cbc, CHB_cbd
19531  global CHB_Cofflab, CHB_Dofflab, awgsync, SWRev, BorderSize
19532  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxEnb, MuxSync, hipulseimg, lowpulseimg
19533  global ShowRMA, ShowRMB, ShowRMC, ShowRMD
19534  global ChopMuxMode, ChopTrig, DualMuxMode, ShowBallonHelp
19535 
19536  if MuxScreenStatus.get() == 0 and DacScreenStatus.get() == 0 and DigScreenStatus.get() == 0:
19537  MuxScreenStatus.set(1)
19538  #
19539  BAWGEnab() # update AWG settings
19540  #
19541  muxwindow = Toplevel()
19542  muxwindow.title("External Mux " + SWRev + RevDate)
19543  muxwindow.resizable(FALSE,FALSE)
19544  muxwindow.protocol("WM_DELETE_WINDOW", DestroyMuxScreen)
19545  #
19546  frameM = LabelFrame(muxwindow, text="External Analog Mux", style="A10.TLabelframe") #
19547  frameM.pack(side=LEFT, expand=1, fill=X)
19548  #
19549  # Voltage channel CHB-A
19550  frameA = Frame(frameM)
19551  frameA.pack(side=TOP)
19552  CHB_cba = Checkbutton(frameA, text='CB-A', style="Strace2.TCheckbutton", variable=Show_CBA, command=UpdateTimeTrace)
19553  CHB_cba.pack(side=LEFT, anchor=W)
19554  CHB_Asb = Spinbox(frameA, width=4, cursor='double_arrow', values=CHvpdiv, command=UpdateTimeTrace)
19555  CHB_Asb.bind('<MouseWheel>', onSpinBoxScroll)
19556  CHB_Asb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
19557  CHB_Asb.bind("<Button-5>", onSpinBoxScroll)
19558  CHB_Asb.pack(side=LEFT)
19559  CHB_Asb.delete(0,"end")
19560  CHB_Asb.insert(0,0.5)
19561  #
19562  CHB_Alab = Button(frameA, text="CB-A V/Div", style="Rtrace2.TButton", command=SetScaleMuxA)
19563  CHB_Alab.pack(side=LEFT)
19564  CHB_APosEntry = Entry(frameA, width=5, cursor='double_arrow')
19565  CHB_APosEntry.bind('<Return>', onTextKey)
19566  CHB_APosEntry.bind('<MouseWheel>', onTextScroll)
19567  CHB_APosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
19568  CHB_APosEntry.bind("<Button-5>", onTextScroll)
19569  CHB_APosEntry.bind('<Key>', onTextKey)
19570  CHB_APosEntry.pack(side=LEFT)
19571  CHB_APosEntry.delete(0,"end")
19572  CHB_APosEntry.insert(0,2.5)
19573  CHB_Aofflab = Button(frameA, text="CB-A Pos", style="Rtrace2.TButton", command=SetMuxAPoss)
19574  CHB_Aofflab.pack(side=LEFT)
19575  # Voltage channel CHB-B
19576  frameB = Frame(frameM)
19577  frameB.pack(side=TOP)
19578  CHB_cbb = Checkbutton(frameB, text='CB-B', style="Strace6.TCheckbutton", variable=Show_CBB, command=UpdateTimeTrace)
19579  CHB_cbb.pack(side=LEFT, anchor=W)
19580  CHB_Bsb = Spinbox(frameB, width=4, cursor='double_arrow', values=CHvpdiv, command=UpdateTimeTrace)
19581  CHB_Bsb.bind('<MouseWheel>', onSpinBoxScroll)
19582  CHB_Bsb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
19583  CHB_Bsb.bind("<Button-5>", onSpinBoxScroll)
19584  CHB_Bsb.pack(side=LEFT)
19585  CHB_Bsb.delete(0,"end")
19586  CHB_Bsb.insert(0,0.5)
19587  CHB_Blab = Button(frameB, text="CB-B V/Div", style="Rtrace6.TButton", command=SetScaleMuxB)
19588  CHB_Blab.pack(side=LEFT)
19589  CHB_BPosEntry = Entry(frameB, width=5, cursor='double_arrow')
19590  CHB_BPosEntry.bind('<Return>', onTextKey)
19591  CHB_BPosEntry.bind('<MouseWheel>', onTextScroll)
19592  CHB_BPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
19593  CHB_BPosEntry.bind("<Button-5>", onTextScroll)
19594  CHB_BPosEntry.bind('<Key>', onTextKey)
19595  CHB_BPosEntry.pack(side=LEFT)
19596  CHB_BPosEntry.delete(0,"end")
19597  CHB_BPosEntry.insert(0,2.5)
19598  CHB_Bofflab = Button(frameB, text="CB-B Pos", style="Rtrace6.TButton", command=SetMuxBPoss)
19599  CHB_Bofflab.pack(side=LEFT)
19600  # Voltage channel B-C
19601  frameC = Frame(frameM)
19602  frameC.pack(side=TOP)
19603  CHB_cbc = Checkbutton(frameC, text='CB-C', style="Strace7.TCheckbutton", variable=Show_CBC, command=UpdateTimeTrace)
19604  CHB_cbc.pack(side=LEFT, anchor=W)
19605  CHB_Csb = Spinbox(frameC, width=4, cursor='double_arrow', values=CHvpdiv, command=UpdateTimeTrace)
19606  CHB_Csb.bind('<MouseWheel>', onSpinBoxScroll)
19607  CHB_Csb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
19608  CHB_Csb.bind("<Button-5>", onSpinBoxScroll)
19609  CHB_Csb.pack(side=LEFT)
19610  CHB_Csb.delete(0,"end")
19611  CHB_Csb.insert(0,0.5)
19612  #
19613  CHB_Clab = Button(frameC, text="CB-C V/Div", style="Rtrace7.TButton", command=SetScaleMuxC)
19614  CHB_Clab.pack(side=LEFT)
19615  CHB_CPosEntry = Entry(frameC, width=5, cursor='double_arrow')
19616  CHB_CPosEntry.bind('<Return>', onTextKey)
19617  CHB_CPosEntry.bind('<MouseWheel>', onTextScroll)
19618  CHB_CPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
19619  CHB_CPosEntry.bind("<Button-5>", onTextScroll)
19620  CHB_CPosEntry.bind('<Key>', onTextKey)
19621  CHB_CPosEntry.pack(side=LEFT)
19622  CHB_CPosEntry.delete(0,"end")
19623  CHB_CPosEntry.insert(0,2.5)
19624  CHB_Cofflab = Button(frameC, text="CB-C Pos", style="Rtrace7.TButton", command=SetMuxCPoss)
19625  CHB_Cofflab.pack(side=LEFT)
19626  # Voltage channel B-D
19627  frameD = Frame(frameM)
19628  frameD.pack(side=TOP)
19629  CHB_cbd = Checkbutton(frameD, text='CB-D', style="Strace4.TCheckbutton", variable=Show_CBD, command=UpdateTimeTrace)
19630  CHB_cbd.pack(side=LEFT, anchor=W)
19631  CHB_Dsb = Spinbox(frameD, width=4, cursor='double_arrow', values=CHvpdiv, command=UpdateTimeTrace)
19632  CHB_Dsb.bind('<MouseWheel>', onSpinBoxScroll)
19633  CHB_Dsb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
19634  CHB_Dsb.bind("<Button-5>", onSpinBoxScroll)
19635  CHB_Dsb.pack(side=LEFT)
19636  CHB_Dsb.delete(0,"end")
19637  CHB_Dsb.insert(0,0.5)
19638  CHB_Dlab = Button(frameD, text="CB-D V/Div", style="Rtrace4.TButton", command=SetScaleMuxD)
19639  CHB_Dlab.pack(side=LEFT)
19640  CHB_DPosEntry = Entry(frameD, width=5, cursor='double_arrow')
19641  CHB_DPosEntry.bind('<Return>', onTextKey)
19642  CHB_DPosEntry.bind('<MouseWheel>', onTextScroll)
19643  CHB_DPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
19644  CHB_DPosEntry.bind("<Button-5>", onTextScroll)
19645  CHB_DPosEntry.bind('<Key>', onTextKey)
19646  CHB_DPosEntry.pack(side=LEFT)
19647  CHB_DPosEntry.delete(0,"end")
19648  CHB_DPosEntry.insert(0,2.5)
19649  CHB_Dofflab = Button(frameD, text="CB-D Pos", style="Rtrace4.TButton", command=SetMuxDPoss)
19650  CHB_Dofflab.pack(side=LEFT)
19651  #
19652  frameR = Frame(frameM)
19653  frameR.pack(side=TOP)
19654  RefTraceMenu = Menubutton(frameR, text="Reference Traces", width=17, style="W17.TButton")
19655  RefTraceMenu.menu = Menu(RefTraceMenu, tearoff = 0 )
19656  RefTraceMenu["menu"] = RefTraceMenu.menu
19657  RefTraceMenu.menu.add_command(label="-Take Snap Shot", command=BSnapShot)
19658  RefTraceMenu.menu.add_command(label="-Ref MUX trace-", foreground="blue", command=donothing)
19659  RefTraceMenu.menu.add_checkbutton(label='RMuxA', background=COLORtraceR2, variable=ShowRMA, command=UpdateTimeTrace)
19660  RefTraceMenu.menu.add_checkbutton(label='RMuxB', background=COLORtraceR6, variable=ShowRMB, command=UpdateTimeTrace)
19661  RefTraceMenu.menu.add_checkbutton(label='RMuxC', background=COLORtraceR7, variable=ShowRMC, command=UpdateTimeTrace)
19662  RefTraceMenu.menu.add_checkbutton(label='RMuxD', background=COLORtraceR4, variable=ShowRMD, command=UpdateTimeTrace)
19663  RefTraceMenu.pack(side=LEFT)
19664  #
19665  frameE = Frame(frameM)
19666  frameE.pack(side=TOP)
19667  muxenab = Checkbutton(frameE, text="Mux-Enb", variable=MuxEnb)
19668  muxenab.pack(side=LEFT)
19669  SyncButton = Checkbutton(frameE, compound=TOP, image=hipulseimg, variable=MuxSync, command=SyncImage)
19670  SyncButton.pack(side=LEFT)
19671  dismissbutton = Button(frameE, text="Dismiss", style="W8.TButton", command=DestroyMuxScreen)
19672  dismissbutton.pack(side=LEFT)
19673  frameF = Frame(frameM)
19674  frameF.pack(side=TOP)
19675  dmx = Checkbutton(frameF, text='Dual Mux Split I/O mode', variable=DualMuxMode, command=SetDualMuxMode)
19676  dmx.pack(side=LEFT)
19677  frameCH = Frame(frameM)
19678  frameCH.pack(side=TOP)
19679  altmx = Radiobutton(frameCH, text='Alternate Sweep', variable=ChopMuxMode, value=0, command=SetChopMuxMode)
19680  altmx.pack(side=LEFT)
19681  chopmx = Radiobutton(frameCH, text='Chop Sweep', variable=ChopMuxMode, value=1, command=SetChopMuxMode)
19682  chopmx.pack(side=LEFT)
19683  frameCT = Frame(frameM)
19684  frameCT.pack(side=TOP)
19685  # Chope Mode trigger drop-down
19686  ChopTrigMenu = Menubutton(frameCT, text="Chop Mode Trigger", width=17, style="W17.TButton")
19687  ChopTrigMenu.menu = Menu(ChopTrigMenu, tearoff = 0 )
19688  ChopTrigMenu["menu"] = ChopTrigMenu.menu
19689  ChopTrigMenu.menu.add_command(label="-MUX Chan-", foreground="blue", command=donothing)
19690  ChopTrigMenu.menu.add_radiobutton(label="None", variable=ChopTrig, value=0) #, command=BAWGBModeLabel)
19691  ChopTrigMenu.menu.add_radiobutton(label="Mux A", variable=ChopTrig, value=1) #, command=BAWGBModeLabel)
19692  ChopTrigMenu.menu.add_radiobutton(label="Mux B", variable=ChopTrig, value=2) #, command=BAWGBModeLabel)
19693  ChopTrigMenu.menu.add_radiobutton(label="Mux C", variable=ChopTrig, value=3) #, command=BAWGBModeLabel)
19694  ChopTrigMenu.menu.add_radiobutton(label="Mux D", variable=ChopTrig, value=4) #, command=BAWGBModeLabel)
19695  ChopTrigMenu.pack(side=LEFT)
19696  #
19697  SaveMuxmenu = Menubutton(frameCT, text="Export csv", width=10, style="W17.TButton")
19698  SaveMuxmenu.menu = Menu(ChopTrigMenu, tearoff = 0 )
19699  SaveMuxmenu["menu"] = SaveMuxmenu.menu
19700  SaveMuxmenu.menu.add_command(label="Save Mux traces", command=BSaveMuxData)
19701  SaveMuxmenu.menu.add_command(label="Save single channel", command=BSaveChannelData)
19702  SaveMuxmenu.pack(side=LEFT)
19703  # Gray out main Channel B controls
19704  CHBlab.config(style="SGray.TButton")
19705  CHBofflab.config(style="SGray.TButton")
19706 
19707  #
19708  if ShowBallonHelp > 0:
19709  CHB_Alab_tip = CreateToolTip(CHB_Alab, 'Select CB-A vertical range/position axis to be used for markers and drawn color')
19710  CHB_Blab_tip = CreateToolTip(CHB_Blab, 'Select CB-B vertical range/position axis to be used for markers and drawn color')
19711  CHB_Clab_tip = CreateToolTip(CHB_Clab, 'Select CB-C vertical range/position axis to be used for markers and drawn color')
19712  CHB_Dlab_tip = CreateToolTip(CHB_Dlab, 'Select CB-D vertical range/position axis to be used for markers and drawn color')
19713  CHB_Aofflab_tip = CreateToolTip(CHB_Aofflab, 'Set CB-A position to DC average of signal')
19714  CHB_Bofflab_tip = CreateToolTip(CHB_Bofflab, 'Set CB-B position to DC average of signal')
19715  CHB_Cofflab_tip = CreateToolTip(CHB_Cofflab, 'Set CB-C position to DC average of signal')
19716  CHB_Dofflab_tip = CreateToolTip(CHB_Dofflab, 'Set CB-D position to DC average of signal')
19717  ChopTrigMenu_tip = CreateToolTip(ChopTrigMenu, 'Menu to Select Trigger Source')
19718  RefTraceMenu_tip = CreateToolTip(RefTraceMenu, 'Menu to Select Mux Reference Traces')
19719  SaveMuxmenu_tip = CreateToolTip(SaveMuxmenu, 'Menu to Export Mux Trace Data to .csv file')
19720 #
19721 def SetDualMuxMode():
19722  global AWGAIOMode, AWGBIOMode, ShowC1_V, DualMuxMode, CHAlab, CHAofflab
19723  global CHB_Clab, CHB_Dlab, CHB_Cofflab, CHB_Dofflab, CHB_cbc, CHB_cbd
19724 
19725  if DualMuxMode.get() == 1:
19726  AWGAIOMode.set(1) # force awg A split I/O mode
19727  AWGBIOMode.set(1) # force awg B split I/O mode
19728  ShowC1_V.set(0) # force A voltage trace off
19729  CHB_cbc.config(text="CA-C")
19730  CHB_cbd.config(text="CA-D")
19731  CHB_Clab.config(text="CA-C V/Div")
19732  CHB_Dlab.config(text="CA-D V/Div")
19733  CHB_Cofflab.config(text="CA-C Pos")
19734  CHB_Dofflab.config(text="CA-D Pos")
19735  BAWGEnab() # update AWG settings
19736  # Gray out main Channel A controls
19737  CHAlab.config(style="SGray.TButton")
19738  CHAofflab.config(style="SGray.TButton")
19739  else:
19740  ShowC1_V.set(1) # force A voltage trace on
19741  CHB_cbc.config(text="CB-C")
19742  CHB_cbd.config(text="CB-D")
19743  CHB_Clab.config(text="CB-C V/Div")
19744  CHB_Dlab.config(text="CB-D V/Div")
19745  CHB_Cofflab.config(text="CB-C Pos")
19746  CHB_Dofflab.config(text="CB-D Pos")
19747  # Reset main Channel A control colors
19748  CHAlab.config(style="Rtrace1.TButton")
19749  CHAofflab.config(style="Rtrace1.TButton")
19750 #
19751 def SetChopMuxMode():
19752  global ChopMuxMode, AWGAIOMode, AWGBIOMode, AWGAMode, AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry
19753  global AWGAPhaseEntry, SAMPLErate, ShowC1_V, ShowC2_V, TgInput
19754 
19755  if ChopMuxMode.get() > 0: # set AWG A to a square wave at 25 KHz 0.5 to 4.5 V, mode = SVMI_SPLIT
19756  AWGAIOMode.set(1) # force awg A split I/O mode
19757  AWGAMode.set(0) # force awg A mode to SVMI
19758  BAWGAModeLabel()
19759  AWGAShape.set(4) # force awg A to square shape
19760  AWGAAmplEntry.delete(0,"end")
19761  AWGAAmplEntry.insert(0,0.5) # force awg A Min value to 0.5 V
19762  AWGAOffsetEntry.delete(0,"end")
19763  AWGAOffsetEntry.insert(0,4.5) # force awg A Max value to 4.5 V
19764  AWGAFreqEntry.delete(0,"end")
19765  AWGAFreqEntry.insert(0,SAMPLErate/4) # force awg A Freg value to 25000 (1/4 base sample rate)
19766  AWGAPhaseEntry.delete(0,"end")
19767  AWGAPhaseEntry.insert(0,0) # force awg A Phase value to 0
19768  ReMakeAWGwaves()
19769  AWGBIOMode.set(1) # force awg A split I/O mode
19770  BAWGBModeLabel()
19771  ShowC1_V.set(0) # force A voltage trace off
19772  ShowC2_V.set(0) # force B voltage trace off
19773  TgInput.set(0) # force main Trigger source to none
19774  CHAlab.config(style="SGray.TButton")
19775  CHAofflab.config(style="SGray.TButton")
19776  else:
19777  CHAlab.config(style="Rtrace1.TButton")
19778  CHAofflab.config(style="Rtrace1.TButton")
19779 
19780 def SyncImage():
19781  global MuxSync, hipulseimg, lowpulseimg, SyncButton
19782 
19783  if MuxSync.get() == 0:
19784  SyncButton.config(image=hipulseimg)
19785  else:
19786  SyncButton.config(image=lowpulseimg)
19787 
19788 def DestroyMuxScreen():
19789  global muxwindow, awgsync, MuxScreenStatus, CHAlab, CHAofflab, CHBlab, CHBofflab
19790  global ChopTrig, ChopMuxMode, MarkerScale
19791 
19792  MuxScreenStatus.set(0)
19793  awgsync.config(state=NORMAL)
19794  ChopMuxMode.set(0)
19795  ChopTrig.set(0)
19796  MarkerScale.set(0)
19797  # Reset main Channel B control colors
19798  CHBlab.config(style="Rtrace2.TButton")
19799  CHBofflab.config(style="Rtrace2.TButton")
19800  CHAlab.config(style="Rtrace1.TButton")
19801  CHAofflab.config(style="Rtrace1.TButton")
19802  muxwindow.destroy()
19803 #
19804 def BodeCaresize(event):
19805  global Bodeca, GRWBP, XOLBP, GRHBP, Y0TBP, CANVASwidthBP, CANVASheightBP, FontSize
19806 
19807  CANVASwidthBP = event.width - 4
19808  CANVASheightBP = event.height - 4
19809  GRWBP = CANVASwidthBP - (2 * X0LBP) # new grid width
19810  GRHBP = CANVASheightBP - int(10 * FontSize) # new grid height
19811  UpdateBodeAll()
19812 #
19813 def BStepSync():
19814  global FStepSync, DevOne
19815 
19816  if FStepSync.get() == 0:
19817  Tval = devx.ctrl_transfer( 0xc0, 0x91, 0, 0, 0, 1, 100) # set PIO-0 to Z
19818  elif FStepSync.get() == 1:
19819  devx.ctrl_transfer( 0x40, 0x50, 0, 0, 0, 0, 100) # set PIO-0 to 0
19820  elif FStepSync.get() == 2:
19821  devx.ctrl_transfer( 0x40, 0x51, 0, 0, 0, 0, 100) # set PIO-0 to 1
19822 #
19823 def BSweepSync():
19824  global FSweepSync, DevOne
19825 
19826  if FSweepSync.get() == 0:
19827  Tval = devx.ctrl_transfer( 0xc0, 0x91, 1, 0, 0, 1, 100) # set PIO-1 to Z
19828  elif FSweepSync.get() == 1:
19829  devx.ctrl_transfer( 0x40, 0x50, 1, 0, 0, 0, 100) # set PIO-1 to 0
19830  elif FSweepSync.get() == 2:
19831  devx.ctrl_transfer( 0x40, 0x51, 1, 0, 0, 0, 100) # set PIO-1 to 1
19832 #
19833 def BDSweepFromFile():
19834  global BDSweepFile, FileSweepFreq, FileSweepAmpl
19835 
19836  if BDSweepFile.get() > 0:
19837  # Read values from CVS file
19838  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent = bodewindow)
19839  try:
19840  CSVFile = open(filename)
19841  csv_f = csv.reader(CSVFile)
19842  FileSweepFreq = []
19843  FileSweepAmpl = []
19844  for row in csv_f:
19845  try:
19846  FileSweepFreq.append(float(row[0]))
19847  FileSweepAmpl.append(float(row[1]))
19848  except:
19849  print( 'skipping non-numeric row')
19850  FileSweepFreq = numpy.array(FileSweepFreq)
19851  FileSweepAmpl = numpy.array(FileSweepAmpl)
19852  MaxAmpl = numpy.amax(FileSweepAmpl)
19853  NormAmpl = MaxAmpl
19854  s = askstring("Normalize Max Amplitude", "Max Amplitude = " + str(MaxAmpl) + "\n\n Enter New Max value:\n in dB", parent = bodewindow)
19855  if (s == None): # If Cancel pressed, then None
19856  return()
19857  try: # Error if for example no numeric characters or OK pressed without input (s = "")
19858  v = int(s)
19859  except:
19860  s = "error"
19861 
19862  if s != "error":
19863  NormAmpl = MaxAmpl - v
19864  else:
19865  NormAmpl = MaxAmpl
19866  FileSweepAmpl = FileSweepAmpl - NormAmpl # normalize max amplitude to requested dBV
19867  CSVFile.close()
19868  StopBodeEntry.delete(0,"end")
19869  StopBodeEntry.insert(0,FileSweepFreq[len(FileSweepFreq)-1])
19870  StartBodeEntry.delete(0,"end")
19871  StartBodeEntry.insert(0,FileSweepFreq[0])
19872  SweepStepBodeEntry.delete(0,"end")
19873  SweepStepBodeEntry.insert(0,len(FileSweepFreq))
19874  except:
19875  showwarning("WARNING","No such file found or wrong format!", parent = bodewindow)
19876 #
19877 # ========== Make Bode Plot Window =============
19878 def MakeBodeWindow():
19879  global logo, SmoothCurvesBP, CutDC, bodewindow, SWRev
19880  global CANVASwidthBP, CANVASheightBP, FFTwindow, CutDC, AWGAMode, AWGAShape, AWGBMode
19881  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, ShowMarkerBP, BodeDisp, RelPhaseCenter
19882  global ShowCA_RdB, ShowCA_RP, ShowCB_RdB, ShowCB_RP, ShowMathBP, ShowRMathBP, PhCenBodeEntry
19883  global BPSweepMode, BPSweepCont, Bodeca, BodeScreenStatus, RevDate, SweepStepBodeEntry
19884  global HScaleBP, StopBodeEntry, StartBodeEntry, ShowBPCur, ShowBdBCur, BPCursor, BdBCursor
19885  global GRWBP, GRHBP, X0LBP, FStepSync, FSweepSync, BDSweepFile, MinigenScreenStatus
19886  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle, ImpedanceCenter, ImCenBodeEntry
19887  global Show_RseriesRef, Show_XseriesRef, Show_MagnitudeRef, Show_AngleRef
19888  global FrameRefief, BorderSize, LocalLanguage
19889  global sbode_tip, rbode_tip, bd3_tip, bd4_tip, bd5_tip, bd6_tip, bd7_tip, bd8_tip, bodismiss1button_tip
19890  global bstopfreqlab, bstartfreqlab, ImCenlab, BPhCenlab
19891 
19892  if BodeScreenStatus.get() == 0:
19893  BodeScreenStatus.set(1)
19894  BodeDisp.set(1)
19895  BodeCheckBox()
19896  CANVASwidthBP = GRWBP + 2 * X0LBP # The Bode canvas width
19897  CANVASheightBP = GRHBP + int(10 * FontSize) # The bode canvas height
19898  CutDC.set(1) # set to remove DC
19899  AWGAMode.set(0) # Set AWG A to SVMI
19900  AWGAShape.set(1) # Set Shape to Sine
19901  AWGBMode.set(2) # Set AWG B to Hi-Z
19902  bodewindow = Toplevel()
19903  bodewindow.title("Bode Plotter " + SWRev + RevDate)
19904  bodewindow.protocol("WM_DELETE_WINDOW", DestroyBodeScreen)
19905  frame2bp = Frame(bodewindow, borderwidth=BorderSize, relief=FrameRefief)
19906  frame2bp.pack(side=RIGHT, expand=NO, fill=BOTH)
19907 
19908  frame2b = Frame(bodewindow, borderwidth=BorderSize, relief=FrameRefief)
19909  frame2b.pack(side=TOP, expand=YES, fill=BOTH)
19910 
19911  Bodeca = Canvas(frame2b, width=CANVASwidthBP, height=CANVASheightBP, background=COLORcanvas, cursor='cross')
19912  Bodeca.bind('<Configure>', BodeCaresize)
19913  Bodeca.bind('<1>', onCanvasBodeLeftClick)
19914  Bodeca.bind('<3>', onCanvasBodeRightClick)
19915  Bodeca.bind("<Up>", onCanvasUpArrow)
19916  Bodeca.bind("<Down>", onCanvasDownArrow)
19917  Bodeca.bind("<Left>", onCanvasLeftArrow)
19918  Bodeca.bind("<Right>", onCanvasRightArrow)
19919  Bodeca.bind("<space>", onCanvasSpaceBar)
19920  Bodeca.bind("1", onCanvasBdOne)
19921  Bodeca.bind("2", onCanvasBdTwo)
19922  Bodeca.bind("3", onCanvasBdThree)
19923  Bodeca.bind("4", onCanvasBdFour)
19924  Bodeca.bind("5", onCanvasBdFive)
19925  Bodeca.bind("6", onCanvasBdSix)
19926  Bodeca.bind("7", onCanvasBdSeven)
19927  Bodeca.bind("8", onCanvasBdEight)
19928  Bodeca.bind("9", onCanvasBdNine)
19929  Bodeca.bind("0", onCanvasBdZero)
19930  Bodeca.bind("f", onCanvasShowBPcur)
19931  Bodeca.bind("d", onCanvasShowBdBcur)
19932  Bodeca.bind("h", onCanvasShowPdBcur)
19933  Bodeca.bind("s", onCanvasBdSnap)
19934  Bodeca.pack(side=TOP, expand=YES, fill=BOTH)
19935 
19936  # right side drop down menu buttons
19937  dropmenu = Frame( frame2bp )
19938  dropmenu.pack(side=TOP)
19939  # File menu
19940  BodeFilemenu = Menubutton(dropmenu, text="File", style="W5.TButton")
19941  BodeFilemenu.menu = Menu(BodeFilemenu, tearoff = 0 )
19942  BodeFilemenu["menu"] = BodeFilemenu.menu
19943  BodeFilemenu.menu.add_command(label="Save Config", command=BSaveConfigBP)
19944  BodeFilemenu.menu.add_command(label="Load Config", command=BLoadConfigBP)
19945  BodeFilemenu.menu.add_command(label="Run Script", command=RunScript)
19946  BodeFilemenu.menu.add_command(label="Save Screen", command=BSaveScreenBP)
19947  BodeFilemenu.menu.add_command(label="Save Data", command=BCSVfile)
19948  BodeFilemenu.pack(side=LEFT, anchor=W)
19949  #
19950  BodeOptionmenu = Menubutton(dropmenu, text="Options", style="W8.TButton")
19951  BodeOptionmenu.menu = Menu(BodeOptionmenu, tearoff = 0 )
19952  BodeOptionmenu["menu"] = BodeOptionmenu.menu
19953  BodeOptionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
19954  BodeOptionmenu.menu.add_checkbutton(label='Smooth', variable=SmoothCurvesBP)
19955  BodeOptionmenu.menu.add_checkbutton(label='Cut-DC', variable=CutDC)
19956  BodeOptionmenu.menu.add_command(label="Store trace (s)", command=BSTOREtraceBP)
19957  BodeOptionmenu.menu.add_radiobutton(label='Black BG', variable=ColorMode, value=0, command=BgColor)
19958  BodeOptionmenu.menu.add_radiobutton(label='White BG', variable=ColorMode, value=1, command=BgColor)
19959  BodeOptionmenu.menu.add_command(label="-Step Sync Pulse-", command=donothing)
19960  BodeOptionmenu.menu.add_radiobutton(label='None', variable=FStepSync, value=0, command=BStepSync)
19961  BodeOptionmenu.menu.add_radiobutton(label='Rising', variable=FStepSync, value=1, command=BStepSync)
19962  BodeOptionmenu.menu.add_radiobutton(label='Falling', variable=FStepSync, value=2, command=BStepSync)
19963  BodeOptionmenu.menu.add_command(label="-Sweep Sync Pulse-", command=donothing)
19964  BodeOptionmenu.menu.add_radiobutton(label='None', variable=FSweepSync, value=0, command=BSweepSync)
19965  BodeOptionmenu.menu.add_radiobutton(label='Rising', variable=FSweepSync, value=1, command=BSweepSync)
19966  BodeOptionmenu.menu.add_radiobutton(label='Falling', variable=FSweepSync, value=2, command=BSweepSync)
19967  BodeOptionmenu.pack(side=LEFT, anchor=W)
19968  #
19969  RUNframe = Frame( frame2bp )
19970  RUNframe.pack(side=TOP)
19971  rbode = Button(RUNframe, text="Run", style="Run.TButton", command=BStartBP)
19972  rbode.pack(side=LEFT)
19973  sbode = Button(RUNframe, text="Stop", style="Stop.TButton", command=BStopBP)
19974  sbode.pack(side=LEFT)
19975  #
19976  BodeFFTwindmenu = Menubutton(frame2bp, text="FFTwindow", style="W11.TButton")
19977  BodeFFTwindmenu.menu = Menu(BodeFFTwindmenu, tearoff = 0 )
19978  BodeFFTwindmenu["menu"] = BodeFFTwindmenu.menu
19979  BodeFFTwindmenu.menu.add_radiobutton(label='Rectangular window (B=1)', variable=FFTwindow, value=0)
19980  BodeFFTwindmenu.menu.add_radiobutton(label='Cosine window (B=1.24)', variable=FFTwindow, value=1)
19981  BodeFFTwindmenu.menu.add_radiobutton(label='Triangular window (B=1.33)', variable=FFTwindow, value=2)
19982  BodeFFTwindmenu.menu.add_radiobutton(label='Hann window (B=1.5)', variable=FFTwindow, value=3)
19983  BodeFFTwindmenu.menu.add_radiobutton(label='Blackman window (B=1.73)', variable=FFTwindow, value=4)
19984  BodeFFTwindmenu.menu.add_radiobutton(label='Nuttall window (B=2.02)', variable=FFTwindow, value=5)
19985  BodeFFTwindmenu.menu.add_radiobutton(label='Flat top window (B=3.77)', variable=FFTwindow, value=6)
19986  BodeFFTwindmenu.menu.add_radiobutton(label='User Defined window', variable=FFTwindow, value=7)
19987  BodeFFTwindmenu.menu.add_command(label="Enter User function", command=BUserFFTwindow)
19988  BodeFFTwindmenu.menu.add_radiobutton(label='FFT Window from file', variable=FFTwindow, value=8, command=BFileFFTwindow)
19989  BodeFFTwindmenu.pack(side=TOP)
19990  #
19991  tracemenu = Frame( frame2bp )
19992  tracemenu.pack(side=TOP)
19993  # Curves menu
19994  # Show channels menu
19995  BodeShowmenu = Menubutton(tracemenu, text="Curves", style="W7.TButton")
19996  BodeShowmenu.menu = Menu(BodeShowmenu, tearoff = 0 )
19997  BodeShowmenu["menu"] = BodeShowmenu.menu
19998  BodeShowmenu.menu.add_command(label="-Show-", command=donothing)
19999  BodeShowmenu.menu.add_command(label="All", command=BShowCurvesAllBP)
20000  BodeShowmenu.menu.add_command(label="None", command=BShowCurvesNoneBP)
20001  BodeShowmenu.menu.add_checkbutton(label='CA-dBV (1)', variable=ShowCA_VdB, command=UpdateBodeAll)
20002  BodeShowmenu.menu.add_checkbutton(label='CB-dBV (2)', variable=ShowCB_VdB, command=UpdateBodeAll)
20003  BodeShowmenu.menu.add_checkbutton(label='Phase A-B (3)', variable=ShowCA_P, command=UpdateBodeAll)
20004  BodeShowmenu.menu.add_checkbutton(label='Phase B-A (4)', variable=ShowCB_P, command=UpdateBodeAll)
20005  BodeShowmenu.menu.add_command(label="-Math-", command=donothing)
20006  BodeShowmenu.menu.add_radiobutton(label='None (0)', variable=ShowMathBP, value=0, command=UpdateBodeAll)
20007  BodeShowmenu.menu.add_radiobutton(label='CA-dB - CB-dB (9)', variable=ShowMathBP, value=1, command=UpdateBodeAll)
20008  BodeShowmenu.menu.add_radiobutton(label='CB-dB - CA-dB (8)', variable=ShowMathBP, value=2, command=UpdateBodeAll)
20009  BodeShowmenu.menu.add_command(label="-Impedance-", command=donothing)
20010  BodeShowmenu.menu.add_checkbutton(label='Series R', variable=Show_Rseries, command=UpdateBodeAll)
20011  BodeShowmenu.menu.add_checkbutton(label='Series X', variable=Show_Xseries, command=UpdateBodeAll)
20012  BodeShowmenu.menu.add_checkbutton(label='Series Mag', variable= Show_Magnitude, command=UpdateBodeAll)
20013  BodeShowmenu.menu.add_checkbutton(label='Series Ang', variable=Show_Angle, command=UpdateBodeAll)
20014  BodeShowmenu.menu.add_separator()
20015  BodeShowmenu.menu.add_checkbutton(label='RA-dBV (6)', variable=ShowCA_RdB, command=UpdateBodeAll)
20016  BodeShowmenu.menu.add_checkbutton(label='RB-dBV (7)', variable=ShowCB_RdB, command=UpdateBodeAll)
20017  BodeShowmenu.menu.add_checkbutton(label='RPhase A-B', variable=ShowCA_RP, command=UpdateBodeAll)
20018  BodeShowmenu.menu.add_checkbutton(label='RPhase B-A', variable=ShowCB_RP, command=UpdateBodeAll)
20019  BodeShowmenu.menu.add_checkbutton(label='Math', variable=ShowRMathBP, command=UpdateBodeAll)
20020  BodeShowmenu.menu.add_checkbutton(label='Ref Series R', variable=Show_RseriesRef, command=UpdateBodeAll)
20021  BodeShowmenu.menu.add_checkbutton(label='Ref Series X', variable=Show_XseriesRef, command=UpdateBodeAll)
20022  BodeShowmenu.menu.add_checkbutton(label='Ref Series Mag', variable=Show_MagnitudeRef, command=UpdateBodeAll)
20023  BodeShowmenu.menu.add_checkbutton(label='Ref Series Ang', variable=Show_AngleRef, command=UpdateBodeAll)
20024  BodeShowmenu.pack(side=LEFT, anchor=W)
20025  #
20026  BodeMarkmenu = Menubutton(tracemenu, text="Cursors", style="W7.TButton")
20027  BodeMarkmenu.menu = Menu(BodeMarkmenu, tearoff = 0 )
20028  BodeMarkmenu["menu"] = BodeMarkmenu.menu
20029  BodeMarkmenu.menu.add_command(label="-Cursors&Markers-", command=donothing)
20030  BodeMarkmenu.menu.add_checkbutton(label='Marker (5)', variable=ShowMarkerBP, command=UpdateBodeAll)
20031  BodeMarkmenu.menu.add_checkbutton(label='Freq Cursor', variable=ShowBPCur)
20032  BodeMarkmenu.menu.add_checkbutton(label='dB Cursor', variable=ShowBdBCur)
20033  BodeMarkmenu.menu.add_radiobutton(label='Cursor Off', variable=ShowBdBCur, value=0)
20034  BodeMarkmenu.menu.add_radiobutton(label='dB Cursor (d)', variable=ShowBdBCur, value=1)
20035  BodeMarkmenu.menu.add_radiobutton(label='Phase Cursor (h)', variable=ShowBdBCur, value=2)
20036  BodeMarkmenu.menu.add_checkbutton(label='Freq Cursor (f)', variable=ShowBPCur)
20037  BodeMarkmenu.pack(side=LEFT, anchor=W)
20038  #
20039  # Horz Scale
20040  HzScale = Frame( frame2bp )
20041  HzScale.pack(side=TOP)
20042  brb1 = Radiobutton(HzScale, text="Lin F", variable=HScaleBP, value=0, command=UpdateBodeTrace )
20043  brb1.pack(side=LEFT)
20044  brb2 = Radiobutton(HzScale, text="Log F", variable=HScaleBP, value=1, command=UpdateBodeTrace )
20045  brb2.pack(side=LEFT)
20046 
20047  DBrange = Frame( frame2bp )
20048  DBrange.pack(side=TOP)
20049  bd3 = Button(DBrange, text="+dB/div", style="W8.TButton", command=BDBdiv2BP)
20050  bd3.pack(side=LEFT)
20051  bd4 = Button(DBrange, text="-dB/div", style="W8.TButton", command=BDBdiv1BP)
20052  bd4.pack(side=LEFT)
20053 
20054  LVBrange = Frame( frame2bp )
20055  LVBrange.pack(side=TOP)
20056  bd5 = Button(LVBrange, text="LVL+10", style="W8.TButton", command=Blevel4BP)
20057  bd5.pack(side=LEFT)
20058  bd6 = Button(LVBrange, text="LVL-10", style="W8.TButton", command=Blevel3BP)
20059  bd6.pack(side=LEFT)
20060 
20061  LVSrange = Frame( frame2bp )
20062  LVSrange.pack(side=TOP)
20063  bd7 = Button(LVSrange, text="LVL+1", style="W8.TButton", command=Blevel2BP)
20064  bd7.pack(side=LEFT)
20065  bd8 = Button(LVSrange, text="LVL-1", style="W8.TButton", command=Blevel1BP)
20066  bd8.pack(side=LEFT)
20067 
20068  PhaseCenter = Frame( frame2bp )
20069  PhaseCenter.pack(side=TOP)
20070  BPhCenlab = Label(PhaseCenter, text="Center Phase on")
20071  BPhCenlab.pack(side=LEFT)
20072  PhCenBodeEntry = Entry(PhaseCenter, width=5, cursor='double_arrow')
20073  PhCenBodeEntry.bind('<Return>', onTextKey)
20074  PhCenBodeEntry.bind('<MouseWheel>', onTextScroll)
20075  PhCenBodeEntry.bind("<Button-4>", onTextScroll)# with Linux OS
20076  PhCenBodeEntry.bind("<Button-5>", onTextScroll)
20077  PhCenBodeEntry.bind('<Key>', onTextKey)
20078  PhCenBodeEntry.pack(side=LEFT)
20079  PhCenBodeEntry.delete(0,"end")
20080  PhCenBodeEntry.insert(0,RelPhaseCenter.get())
20081  #
20082  ImpedCenter = Frame( frame2bp )
20083  ImpedCenter.pack(side=TOP)
20084  ImCenlab = Label(ImpedCenter, text="Center Imped on")
20085  ImCenlab.pack(side=LEFT)
20086  ImCenBodeEntry = Entry(ImpedCenter, width=5, cursor='double_arrow')
20087  ImCenBodeEntry.bind('<Return>', onTextKey)
20088  ImCenBodeEntry.bind('<MouseWheel>', onTextScroll)
20089  ImCenBodeEntry.bind("<Button-4>", onTextScroll)# with Linux OS
20090  ImCenBodeEntry.bind("<Button-5>", onTextScroll)
20091  ImCenBodeEntry.bind('<Key>', onTextKey)
20092  ImCenBodeEntry.pack(side=LEFT)
20093  ImCenBodeEntry.delete(0,"end")
20094  ImCenBodeEntry.insert(0,ImpedanceCenter.get())
20095  # sweep generator mode menu buttons
20096  FSweepmenu = Label(frame2bp, text="-Sweep Gen-", style="A10B.TLabel")
20097  FSweepmenu.pack(side=TOP)
20098 
20099  Frange1 = Frame( frame2bp )
20100  Frange1.pack(side=TOP)
20101  bstartfreqlab = Label(Frange1, text="Start Freq")
20102  bstartfreqlab.pack(side=LEFT)
20103  StartBodeEntry = Entry(Frange1, width=5, cursor='double_arrow')
20104  StartBodeEntry.bind('<Return>', onTextKey)
20105  StartBodeEntry.bind('<MouseWheel>', onTextScroll)
20106  StartBodeEntry.bind("<Button-4>", onTextScroll)# with Linux OS
20107  StartBodeEntry.bind("<Button-5>", onTextScroll)
20108  StartBodeEntry.bind('<Key>', onTextKey)
20109  StartBodeEntry.pack(side=LEFT)
20110  StartBodeEntry.delete(0,"end")
20111  StartBodeEntry.insert(0,10)
20112 
20113  Frange2 = Frame( frame2bp )
20114  Frange2.pack(side=TOP)
20115  bstopfreqlab = Label(Frange2, text="Stop Freq")
20116  bstopfreqlab.pack(side=LEFT)
20117  StopBodeEntry = Entry(Frange2, width=5, cursor='double_arrow')
20118  StopBodeEntry.bind('<Return>', onTextKey)
20119  StopBodeEntry.bind('<MouseWheel>', onStopBodeScroll)
20120  StopBodeEntry.bind("<Button-4>", onTextScroll)# with Linux OS
20121  StopBodeEntry.bind("<Button-5>", onTextScroll)
20122  StopBodeEntry.bind('<Key>', onTextKey)
20123  StopBodeEntry.pack(side=LEFT)
20124  StopBodeEntry.delete(0,"end")
20125  StopBodeEntry.insert(0,10000)
20126 
20127  sgrb1 = Radiobutton(frame2bp, text='None', variable=FSweepMode, value=0)
20128  sgrb1.pack(side=TOP)
20129  Frange4 = Frame( frame2bp )
20130  Frange4.pack(side=TOP)
20131  sgrb2 = Radiobutton(Frange4, text='CH-A', variable=FSweepMode, value=1)
20132  sgrb2.pack(side=LEFT)
20133  sgrb3 = Radiobutton(Frange4, text='CH-B', variable=FSweepMode, value=2)
20134  sgrb3.pack(side=LEFT)
20135  if MinigenScreenStatus.get() > 0:
20136  sgrb1 = Radiobutton(frame2bp, text='MinGen', variable=FSweepMode, value=3)
20137  sgrb1.pack(side=TOP)
20138  ffcb = Checkbutton(frame2bp, text='Sweep From File', variable=BDSweepFile, command=BDSweepFromFile)
20139  ffcb.pack(side=TOP)
20140  Frange3 = Frame( frame2bp )
20141  Frange3.pack(side=TOP)
20142  sweepsteplab = Label(Frange3, text="Sweep Steps")
20143  sweepsteplab.pack(side=LEFT)
20144  SweepStepBodeEntry = Entry(Frange3, width=5, cursor='double_arrow')
20145  SweepStepBodeEntry.bind('<Return>', onTextKey)
20146  SweepStepBodeEntry.bind('<MouseWheel>', onTextScroll)
20147  SweepStepBodeEntry.bind("<Button-4>", onTextScroll)# with Linux OS
20148  SweepStepBodeEntry.bind("<Button-5>", onTextScroll)
20149  SweepStepBodeEntry.bind('<Key>', onTextKey)
20150  SweepStepBodeEntry.pack(side=LEFT)
20151  SweepStepBodeEntry.delete(0,"end")
20152  SweepStepBodeEntry.insert(0,100)
20153 
20154  sgrb5 = Radiobutton(frame2bp, text='Single', variable=FSweepCont, value=0)
20155  sgrb5.pack(side=TOP)
20156  sgrb6 = Radiobutton(frame2bp, text='Continuous', variable=FSweepCont, value=1)
20157  sgrb6.pack(side=TOP)
20158  Plotsframe = Frame( frame2bp )
20159  Plotsframe.pack(side=TOP)
20160  nyquistplotbutton = Button(Plotsframe, text="Polar Plot", style="W9.TButton", command=MakeNyquistPlot)
20161  nyquistplotbutton.pack(side=LEFT)
20162  nicholsplotbutton = Button(Plotsframe, text="Rect Plot", style="W8.TButton", command=MakeNicPlot)
20163  nicholsplotbutton.pack(side=LEFT)
20164  bodismiss1button = Button(frame2bp, text="Dismiss", style="W8.TButton", command=DestroyBodeScreen)
20165  bodismiss1button.pack(side=TOP)
20166 
20167  ADI2 = Label(frame2bp, image=logo, anchor= "sw", compound="top") #, height=49, width=116
20168  ADI2.pack(side=TOP)
20169  if ShowBallonHelp > 0:
20170  sbode_tip = CreateToolTip(sbode, 'Stop acquiring data')
20171  rbode_tip = CreateToolTip(rbode, 'Start acquiring data')
20172  bd3_tip = CreateToolTip(bd3, 'Increase number of dB/Div')
20173  bd4_tip = CreateToolTip(bd4, 'Decrease number of dB/Div')
20174  bd5_tip = CreateToolTip(bd5, 'Increase Ref Level by 10 dB')
20175  bd6_tip = CreateToolTip(bd6, 'Decrease Ref Level by 10 dB')
20176  bd7_tip = CreateToolTip(bd7, 'Increase Ref Level by 1 dB')
20177  bd8_tip = CreateToolTip(bd8, 'Decrease Ref Level by 1 dB')
20178  bodismiss1button_tip = CreateToolTip(bodismiss1button, 'Dismiss Bode Plot window')
20179  if LocalLanguage != "English":
20180  BLoadConfig(LocalLanguage) # load local language configuration
20181 #
20182 def DestroyBodeScreen():
20183  global bodewindow, BodeScreenStatus, ca, FSweepMode
20184 
20185  BodeScreenStatus.set(0)
20186  FSweepMode.set(0)
20187  BodeDisp.set(0)
20188  BodeCheckBox()
20189  bodewindow.destroy()
20190  ca.bind_all('<MouseWheel>', onCanvasClickScroll)
20191 #
20192 def FreqCaresize(event):
20193  global Freqca, GRWF, XOLF, GRHF, Y0TF, CANVASwidthF, CANVASheightF, FontSize
20194 
20195  CANVASwidthF = event.width - 4
20196  CANVASheightF = event.height - 4
20197  GRWF = CANVASwidthF - 10 - (2 * X0LF) # new grid width
20198  GRHF = CANVASheightF - int(10 * FontSize) # new grid height
20199  UpdateFreqAll()
20200 #
20201 # ================ Make spectrum sub window ==========================
20202 def MakeSpectrumWindow():
20203  global logo, SmoothCurvesSA, CutDC, SingleShotSA, FFTwindow, freqwindow, SmoothCurvesSA
20204  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowMarker, FreqDisp, ShowAWGASA
20205  global ShowRA_VdB, ShowRA_P, ShowRB_VdB, ShowRB_P, ShowMathSA, SWRev, SingleShotSA, ShowAWGBSA
20206  global ShowRMath, FSweepMode, FSweepCont, Freqca, SpectrumScreenStatus, RevDate, AWGShowAdvanced
20207  global HScale, StopFreqEntry, StartFreqEntry, ShowFCur, ShowdBCur, FCursor, dBCursor
20208  global CANVASwidthF, GRWF, X0LF, CANVASheightF, GRHF, FontSize, PhCenFreqEntry, RelPhaseCenter
20209  global FrameRefief, BorderSize, LocalLanguage, SAVScale, SAVPSD, SAvertmaxEntry, SAvertminEntry
20210  global sb_tip, rb_tip, bless_tip, bmore_tip, b3_tip, b4_tip, b5_tip, b6_tip, b7_tip, b8_tip, sadismiss1button_tip
20211  global SAMagdiv, SAVScale, SAvertmaxEntry, SAvertminEntry, SAVPSD
20212 
20213  if SpectrumScreenStatus.get() == 0:
20214  SpectrumScreenStatus.set(1)
20215  FreqDisp.set(1)
20216  FreqCheckBox()
20217  CANVASwidthF = GRWF + 10 + 2 * X0LF # The spectrum canvas width
20218  CANVASheightF = GRHF + int(10 * FontSize) # 80 The spectrum canvas height
20219  freqwindow = Toplevel()
20220  freqwindow.title("Spectrum Analyzer " + SWRev + RevDate)
20221  freqwindow.protocol("WM_DELETE_WINDOW", DestroySpectrumScreen)
20222  frame2fr = Frame(freqwindow, borderwidth=BorderSize, relief=FrameRefief)
20223  frame2fr.pack(side=RIGHT, expand=NO, fill=BOTH)
20224 
20225  frame2f = Frame(freqwindow, borderwidth=BorderSize, relief=FrameRefief)
20226  frame2f.pack(side=TOP, expand=YES, fill=BOTH)
20227 
20228  Freqca = Canvas(frame2f, width=CANVASwidthF, height=CANVASheightF, background=COLORcanvas, cursor='cross')
20229  Freqca.bind('<Configure>', FreqCaresize)
20230  Freqca.bind('<1>', onCanvasFreqLeftClick)
20231  Freqca.bind('<3>', onCanvasFreqRightClick)
20232  Freqca.bind("<Up>", onCanvasUpArrow)
20233  Freqca.bind("<Down>", onCanvasDownArrow)
20234  Freqca.bind("<Left>", onCanvasLeftArrow)
20235  Freqca.bind("<Right>", onCanvasRightArrow)
20236  Freqca.bind("<space>", onCanvasSpaceBar)
20237  Freqca.bind("1", onCanvasSAOne)
20238  Freqca.bind("2", onCanvasSATwo)
20239  Freqca.bind("3", onCanvasSAThree)
20240  Freqca.bind("4", onCanvasSAFour)
20241  Freqca.bind("5", onCanvasSAFive)
20242  Freqca.bind("6", onCanvasSASix)
20243  Freqca.bind("7", onCanvasSASeven)
20244  Freqca.bind("8", onCanvasSAEight)
20245  Freqca.bind("9", onCanvasSANine)
20246  Freqca.bind("0", onCanvasSAZero)
20247  Freqca.bind("a", onCanvasSAAverage)
20248  Freqca.bind("n", onCanvasSANormal)
20249  Freqca.bind("p", onCanvasSAPeak)
20250  Freqca.bind("r", onCanvasSAReset)
20251  Freqca.bind("f", onCanvasShowFcur)
20252  Freqca.bind("d", onCanvasShowdBcur)
20253  Freqca.bind("h", onCanvasShowPcur)
20254  Freqca.bind("s", onCanvasSASnap)
20255  Freqca.pack(side=TOP, expand=YES, fill=BOTH)
20256  # right side drop down menu buttons
20257  dropmenu = Frame( frame2fr )
20258  dropmenu.pack(side=TOP)
20259  # File menu
20260  SAFilemenu = Menubutton(dropmenu, text="File", style="W5.TButton")
20261  SAFilemenu.menu = Menu(SAFilemenu, tearoff = 0 )
20262  SAFilemenu["menu"] = SAFilemenu.menu
20263  SAFilemenu.menu.add_command(label="Save Config", command=BSaveConfigSA)
20264  SAFilemenu.menu.add_command(label="Load Config", command=BLoadConfigSA)
20265  SAFilemenu.menu.add_command(label="Run Script", command=RunScript)
20266  SAFilemenu.menu.add_command(label="Save Screen", command=BSaveScreenSA)
20267  SAFilemenu.menu.add_command(label="Save Data", command=STOREcsvfile)
20268  SAFilemenu.pack(side=LEFT, anchor=W)
20269  #
20270  SAOptionmenu = Menubutton(dropmenu, text="Options", style="W8.TButton")
20271  SAOptionmenu.menu = Menu(SAOptionmenu, tearoff = 0 )
20272  SAOptionmenu["menu"] = SAOptionmenu.menu
20273  SAOptionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
20274  SAOptionmenu.menu.add_command(label='Set Sample Rate', command=MakeSampleRateMenu) # SetSampleRate)
20275  SAOptionmenu.menu.add_checkbutton(label='Smooth', variable=SmoothCurvesSA)
20276  SAOptionmenu.menu.add_checkbutton(label='Cut-DC', variable=CutDC)
20277  SAOptionmenu.menu.add_command(label="Store trace [s]", command=BSTOREtraceSA)
20278  SAOptionmenu.menu.add_radiobutton(label='Black BG', variable=ColorMode, value=0, command=BgColor)
20279  SAOptionmenu.menu.add_radiobutton(label='White BG', variable=ColorMode, value=1, command=BgColor)
20280  SAOptionmenu.pack(side=LEFT, anchor=W)
20281  #
20282  RUNframe = Frame( frame2fr )
20283  RUNframe.pack(side=TOP)
20284  sarb = Button(RUNframe, text="Run", style="Run.TButton", command=BStartSA)
20285  sarb.pack(side=LEFT)
20286  sasb = Button(RUNframe, text="Stop", style="Stop.TButton", command=BStopSA)
20287  sasb.pack(side=LEFT)
20288  #
20289  Modeframe = Frame( frame2fr )
20290  Modeframe.pack(side=TOP)
20291  Modemenu = Menubutton(Modeframe, text="Mode", style="W5.TButton")
20292  Modemenu.menu = Menu(Modemenu, tearoff = 0 )
20293  Modemenu["menu"] = Modemenu.menu
20294  Modemenu.menu.add_command(label="Normal mode [n]", command=BNormalmode)
20295  Modemenu.menu.add_command(label="Peak hold [p]", command=BPeakholdmode)
20296  Modemenu.menu.add_command(label="Average [a]", command=BAveragemode)
20297  Modemenu.menu.add_command(label="Reset Average [r]", command=BResetFreqAvg)
20298  Modemenu.menu.add_checkbutton(label='SingleShot', variable=SingleShotSA)
20299  Modemenu.pack(side=LEFT)
20300  #
20301  SAFFTwindmenu = Menubutton(Modeframe, text="FFTwindow", style="W11.TButton")
20302  SAFFTwindmenu.menu = Menu(SAFFTwindmenu, tearoff = 0 )
20303  SAFFTwindmenu["menu"] = SAFFTwindmenu.menu
20304  SAFFTwindmenu.menu.add_radiobutton(label='Rectangular window (B=1)', variable=FFTwindow, value=0)
20305  SAFFTwindmenu.menu.add_radiobutton(label='Cosine window (B=1.24)', variable=FFTwindow, value=1)
20306  SAFFTwindmenu.menu.add_radiobutton(label='Triangular window (B=1.33)', variable=FFTwindow, value=2)
20307  SAFFTwindmenu.menu.add_radiobutton(label='Hann window (B=1.5)', variable=FFTwindow, value=3)
20308  SAFFTwindmenu.menu.add_radiobutton(label='Blackman window (B=1.73)', variable=FFTwindow, value=4)
20309  SAFFTwindmenu.menu.add_radiobutton(label='Nuttall window (B=2.02)', variable=FFTwindow, value=5)
20310  SAFFTwindmenu.menu.add_radiobutton(label='Flat top window (B=3.77)', variable=FFTwindow, value=6)
20311  SAFFTwindmenu.menu.add_radiobutton(label='User Defined window', variable=FFTwindow, value=7)
20312  SAFFTwindmenu.menu.add_command(label="Enter User function", command=BUserFFTwindow)
20313  SAFFTwindmenu.menu.add_radiobutton(label='FFT Window from file', variable=FFTwindow, value=8, command=BFileFFTwindow)
20314  SAFFTwindmenu.pack(side=LEFT)
20315  #
20316  SamplesMenu = Frame( frame2fr )
20317  SamplesMenu.pack(side=TOP)
20318  bless = Button(SamplesMenu, text="-Samples", style="W8.TButton", command=Bsamples1)
20319  bless.pack(side=LEFT)
20320  bmore = Button(SamplesMenu, text="+Samples", style="W8.TButton", command=Bsamples2)
20321  bmore.pack(side=LEFT)
20322  #
20323  # Show channels menu
20324  #
20325  MarkersMenu = Frame( frame2fr )
20326  MarkersMenu.pack(side=TOP)
20327  SAShowmenu = Menubutton(MarkersMenu, text="Curves", style="W7.TButton")
20328  SAShowmenu.menu = Menu(SAShowmenu, tearoff = 0 )
20329  SAShowmenu["menu"] = SAShowmenu.menu
20330  SAShowmenu.menu.add_command(label="-Show-", command=donothing)
20331  SAShowmenu.menu.add_command(label="All", command=BShowCurvesAllSA)
20332  SAShowmenu.menu.add_command(label="None", command=BShowCurvesNoneSA)
20333  SAShowmenu.menu.add_checkbutton(label='CA-dBV [1]', variable=ShowC1_VdB, command=UpdateFreqAll)
20334  SAShowmenu.menu.add_checkbutton(label='CB-dBV [2]', variable=ShowC2_VdB, command=UpdateFreqAll)
20335  SAShowmenu.menu.add_checkbutton(label='Phase A-B [3]', variable=ShowC1_P, command=UpdateFreqAll)
20336  SAShowmenu.menu.add_checkbutton(label='Phase B-A [4]', variable=ShowC2_P, command=UpdateFreqAll)
20337  SAShowmenu.menu.add_command(label="-Math-", command=donothing)
20338  SAShowmenu.menu.add_radiobutton(label='None [0]', variable=ShowMathSA, value=0, command=UpdateFreqAll)
20339  SAShowmenu.menu.add_radiobutton(label='CA-dB - CB-dB [9]', variable=ShowMathSA, value=1, command=UpdateFreqAll)
20340  SAShowmenu.menu.add_radiobutton(label='CB-dB - CA-dB [8]', variable=ShowMathSA, value=2, command=UpdateFreqAll)
20341  if AWGShowAdvanced.get() > 0:
20342  SAShowmenu.menu.add_command(label="-AWG-", command=donothing)
20343  SAShowmenu.menu.add_checkbutton(label='AWG A', variable=ShowAWGASA, command=UpdateFreqAll)
20344  SAShowmenu.menu.add_checkbutton(label='AWG B', variable=ShowAWGBSA, command=UpdateFreqAll)
20345  SAShowmenu.menu.add_command(label="-Ref Trace-", command=donothing)
20346  SAShowmenu.menu.add_checkbutton(label='RA-dBV [6]', variable=ShowRA_VdB, command=UpdateFreqAll)
20347  SAShowmenu.menu.add_checkbutton(label='RB-dBV [7]', variable=ShowRB_VdB, command=UpdateFreqAll)
20348  SAShowmenu.menu.add_checkbutton(label='RPhase A-B', variable=ShowRA_P, command=UpdateFreqAll)
20349  SAShowmenu.menu.add_checkbutton(label='RPhase B-A', variable=ShowRB_P, command=UpdateFreqAll)
20350  SAShowmenu.menu.add_checkbutton(label='Ref Math', variable=ShowRMath, command=UpdateFreqAll)
20351  SAShowmenu.pack(side=LEFT)
20352  SACursormenu = Menubutton(MarkersMenu, text="Cursors", style="W7.TButton")
20353  SACursormenu.menu = Menu(SACursormenu, tearoff = 0 )
20354  SACursormenu["menu"] = SACursormenu.menu
20355  SACursormenu.menu.add_command(label="-Marker-", command=donothing)
20356  SACursormenu.menu.add_radiobutton(label='Markers Off', variable=ShowMarker, value=0, command=UpdateFreqAll)
20357  SACursormenu.menu.add_radiobutton(label='Markers [5]', variable=ShowMarker, value=1, command=UpdateFreqAll)
20358  SACursormenu.menu.add_radiobutton(label='Delta Markers', variable=ShowMarker, value=2, command=UpdateFreqAll)
20359  SACursormenu.menu.add_command(label="-Cursors-", command=donothing)
20360  SACursormenu.menu.add_radiobutton(label='Cursor Off', variable=ShowdBCur, value=0)
20361  SACursormenu.menu.add_radiobutton(label='dB Cursor [d]', variable=ShowdBCur, value=1)
20362  #SACursormenu.menu.add_radiobutton(label='Phase Cursor [h]', variable=ShowdBCur, value=2)
20363  SACursormenu.menu.add_checkbutton(label='Freq Cursor [f]', variable=ShowFCur)
20364  SACursormenu.pack(side=LEFT)
20365  # HScale
20366  Frange1 = Frame( frame2fr )
20367  Frange1.pack(side=TOP)
20368  startfreqlab = Label(Frange1, text="Startfreq")
20369  startfreqlab.pack(side=LEFT)
20370  StartFreqEntry = Entry(Frange1, width=5, cursor='double_arrow')
20371  StartFreqEntry.bind('<Return>', onTextKey)
20372  StartFreqEntry.bind('<MouseWheel>', onTextScroll)
20373  StartFreqEntry.bind("<Button-4>", onTextScroll)# with Linux OS
20374  StartFreqEntry.bind("<Button-5>", onTextScroll)
20375  StartFreqEntry.bind('<Key>', onTextKey)
20376  StartFreqEntry.pack(side=LEFT)
20377  StartFreqEntry.delete(0,"end")
20378  StartFreqEntry.insert(0,10)
20379 
20380  Frange2 = Frame( frame2fr )
20381  Frange2.pack(side=TOP)
20382  stopfreqlab = Label(Frange2, text="Stopfreq")
20383  stopfreqlab.pack(side=LEFT)
20384  StopFreqEntry = Entry(Frange2, width=7, cursor='double_arrow')
20385  StopFreqEntry.bind('<Return>', onTextKey)
20386  StopFreqEntry.bind('<MouseWheel>', onStopfreqScroll)
20387  StopFreqEntry.bind("<Button-4>", onStopfreqScroll)# with Linux OS
20388  StopFreqEntry.bind("<Button-5>", onStopfreqScroll)
20389  StopFreqEntry.bind('<Key>', onTextKey)
20390  StopFreqEntry.pack(side=LEFT)
20391  StopFreqEntry.delete(0,"end")
20392  StopFreqEntry.insert(0,10000)
20393 
20394  HzScale = Frame( frame2fr )
20395  HzScale.pack(side=TOP)
20396  sarb1 = Radiobutton(HzScale, text="Lin F", variable=HScale, value=0, command=UpdateFreqTrace )
20397  sarb1.pack(side=LEFT)
20398  sarb2 = Radiobutton(HzScale, text="Log F", variable=HScale, value=1, command=UpdateFreqTrace )
20399  sarb2.pack(side=LEFT)
20400  #
20401  PhaseCenter = Frame( frame2fr )
20402  PhaseCenter.pack(side=TOP)
20403  PhCenlab = Label(PhaseCenter, text="Center Phase on")
20404  PhCenlab.pack(side=LEFT)
20405  PhCenFreqEntry = Entry(PhaseCenter, width=5, cursor='double_arrow')
20406  PhCenFreqEntry.bind('<Return>', onTextKey)
20407  PhCenFreqEntry.bind('<MouseWheel>', onTextScroll)
20408  PhCenFreqEntry.bind("<Button-4>", onTextScroll)# with Linux OS
20409  PhCenFreqEntry.bind("<Button-5>", onTextScroll)
20410  PhCenFreqEntry.bind('<Key>', onTextKey)
20411  PhCenFreqEntry.pack(side=LEFT)
20412  PhCenFreqEntry.delete(0,"end")
20413  PhCenFreqEntry.insert(0,RelPhaseCenter.get())
20414  #
20415  vertlabel = Label( frame2fr, text="Vertical Scale" )
20416  vertlabel.pack(side=TOP)
20417  savrb0 = Radiobutton(frame2fr, text="In dB", variable=SAVScale, value=0, command=UpdateFreqTrace )
20418  savrb0.pack(side=TOP)
20419  #
20420  DBrange = Frame( frame2fr )
20421  DBrange.pack(side=TOP)
20422  sab3 = Button(DBrange, text="+dB/div", style="W8.TButton", command=BDBdiv2)
20423  sab3.pack(side=LEFT)
20424  sab4 = Button(DBrange, text="-dB/div", style="W8.TButton", command=BDBdiv1)
20425  sab4.pack(side=LEFT)
20426 
20427  LVBrange = Frame( frame2fr )
20428  LVBrange.pack(side=TOP)
20429  sab5 = Button(LVBrange, text="LVL+10", style="W8.TButton", command=Blevel4)
20430  sab5.pack(side=LEFT)
20431  sab6 = Button(LVBrange, text="LVL-10", style="W8.TButton", command=Blevel3)
20432  sab6.pack(side=LEFT)
20433 
20434  LVSrange = Frame( frame2fr )
20435  LVSrange.pack(side=TOP)
20436  sab7 = Button(LVSrange, text="LVL+1", style="W8.TButton", command=Blevel2)
20437  sab7.pack(side=LEFT)
20438  sab8 = Button(LVSrange, text="LVL-1", style="W8.TButton", command=Blevel1)
20439  sab8.pack(side=LEFT)
20440  # Add RMS V controls
20441  vertscale = Frame( frame2fr )
20442  vertscale.pack(side=TOP)
20443  savlab1 = Label(vertscale, text="V RMS")
20444  savlab1.pack(side=LEFT)
20445  savrb1 = Radiobutton(vertscale, text="Lin", variable=SAVScale, value=1, command=UpdateFreqTrace )
20446  savrb1.pack(side=LEFT)
20447  savrb2 = Radiobutton(vertscale, text="Log", variable=SAVScale, value=2, command=UpdateFreqTrace )
20448  savrb2.pack(side=LEFT)
20449  sapsdcb = Checkbutton(frame2fr, text="PSD (sqrt Hz)", variable=SAVPSD)
20450  sapsdcb.pack(side=TOP)
20451  #
20452  vertmax = Frame( frame2fr )
20453  vertmax.pack(side=TOP)
20454  vertmaxlab = Label(vertmax, text="VRMS Max")
20455  vertmaxlab.pack(side=LEFT)
20456  SAvertmaxEntry = Spinbox(vertmax, width=6, cursor='double_arrow', values=SAMagdiv, command=BCHBIlevel)
20457  SAvertmaxEntry.bind('<MouseWheel>', onSpinBoxScroll)
20458  SAvertmaxEntry.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
20459  SAvertmaxEntry.bind("<Button-5>", onSpinBoxScroll)
20460  SAvertmaxEntry.delete(0,"end")
20461  SAvertmaxEntry.insert(0,"1.0")
20462  SAvertmaxEntry.pack(side=LEFT)
20463 
20473  vertmin = Frame( frame2fr )
20474  vertmin.pack(side=TOP)
20475  vertminlab = Label(vertmin, text="VRMS Min")
20476  vertminlab.pack(side=LEFT)
20477  SAvertminEntry = Spinbox(vertmin, width=6, cursor='double_arrow', values=SAMagdiv, command=BCHBIlevel)
20478  SAvertminEntry.bind('<MouseWheel>', onSpinBoxScroll)
20479  SAvertminEntry.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
20480  SAvertminEntry.bind("<Button-5>", onSpinBoxScroll)
20481  SAvertminEntry.pack(side=LEFT)
20482  SAvertminEntry.delete(0,"end")
20483  SAvertminEntry.insert(0,"100uV")
20484 
20494  sadismiss1button = Button(frame2fr, text="Dismiss", style="W8.TButton", command=DestroySpectrumScreen)
20495  sadismiss1button.pack(side=TOP)
20496 
20497  ADI2 = Label(frame2fr, image=logo, anchor= "sw", compound="top") #, height=49, width=116
20498  ADI2.pack(side=TOP)
20499  if ShowBallonHelp > 0:
20500  sb_tip = CreateToolTip(sasb, 'Stop acquiring data')
20501  rb_tip = CreateToolTip(sarb, 'Start acquiring data')
20502  bless_tip = CreateToolTip(bless, 'Decrease FFT samples')
20503  bmore_tip = CreateToolTip(bmore, 'Increase FFT samples')
20504  b3_tip = CreateToolTip(sab3, 'Increase number of dB/Div')
20505  b4_tip = CreateToolTip(sab4, 'Decrease number of dB/Div')
20506  b5_tip = CreateToolTip(sab5, 'Increase Ref Level by 10 dB')
20507  b6_tip = CreateToolTip(sab6, 'Decrease Ref Level by 10 dB')
20508  b7_tip = CreateToolTip(sab7, 'Increase Ref Level by 1 dB')
20509  b8_tip = CreateToolTip(sab8, 'Decrease Ref Level by 1 dB')
20510  sadismiss1button_tip = CreateToolTip(sadismiss1button, 'Dismiss Spectrum Analyzer window')
20511  if LocalLanguage != "English":
20512  BLoadConfig(LocalLanguage) # load local language configuration
20513 
20514 def DestroySpectrumScreen():
20515  global freqwindow, SpectrumScreenStatus, ca
20516 
20517  SpectrumScreenStatus.set(0)
20518  FreqDisp.set(0)
20519  FreqCheckBox()
20520  freqwindow.destroy()
20521  ca.bind_all('<MouseWheel>', onCanvasClickScroll)
20522 #
20523 def XYcaresize(event):
20524  global XYca, GRWXY, XOLXY, GRHXY, Y0TXY, CANVASwidthXY, CANVASheightXY, FontSize
20525  global YminXY, YmaxXY, XminXY, XmaxXY
20526 
20527  XOLXY = FontSize * 7
20528  CANVASwidthXY = event.width - 4
20529  CANVASheightXY = event.height - 4
20530  GRWXY = CANVASwidthXY - (2*X0LXY) # 18 new grid width
20531  GRHXY = CANVASheightXY - int(10 * FontSize) # new grid height
20532  YminXY = Y0TXY # Minimum position of time grid (top)
20533  YmaxXY = Y0TXY + GRHXY # Maximum position of time grid (bottom)
20534  XminXY = X0LXY # Minimum position of time grid (left)
20535  XmaxXY = X0LXY + GRWXY # Maximum position of time grid (right)
20536  UpdateXYAll()
20537 #
20538 # ================ Make XY Plot sub window ==========================
20539 def MakeXYWindow():
20540  global logo, CANVASwidthXY, CANVASheightXY, Xsignal, EnableUserEntries
20541  global YsignalVA, YsignalVB, YsignalIA, YsignalIB, YsignalM, YsignalMX, YsignalMY
20542  global XYRefAV, XYRefAI, XYRefBV, XYRefBI, XYRefM, XYRefMX, XYRefMY
20543  global XYScreenStatus, MarkerXYScale, XYca, xywindow, RevDate, SWRev, XYDisp
20544  global CHAsbxy, CHBsbxy, CHAxylab, CHBxylab, CHAVPosEntryxy, CHBVPosEntryxy
20545  global CHAIsbxy, CHBIsbxy, CHAIPosEntryxy, CHBIPosEntryxy, ScreenXYrefresh
20546  global YminXY, Y0TXY, YmaxXY, GRHXY, XminXY, X0LXY, XmaxXY, X0LXY, GRWXY, CANVASwidthXY, CANVASheightXY
20547  global FrameRefief, BorderSize, LocalLanguage, User3Entry, User4Entry
20548  global math_tip, bsxy_tip, brxy_tip, snapbutton_tip, savebutton_tip, dismissxybutton_tip, CHAxylab_tip
20549  global CHBxylab_tip, CHAxyofflab_tip, CHBxyofflab_tip, CHAIxyofflab_tip, CHBIxyofflab_tip
20550 
20551  if XYScreenStatus.get() == 0:
20552  XYScreenStatus.set(1)
20553  XYDisp.set(1)
20554  XYCheckBox()
20555  YminXY = Y0TXY # Minimum position of XY grid (top)
20556  YmaxXY = Y0TXY + GRHXY # Maximum position of XY grid (bottom)
20557  XminXY = X0LXY # Minimum position of XY grid (left)
20558  XmaxXY = X0LXY + GRWXY # Maximum position of XY grid (right)
20559  CANVASwidthXY = GRWXY + (2*X0LXY) # The XY canvas width
20560  CANVASheightXY = GRHXY + 80 # The XY canvas height
20561  xywindow = Toplevel()
20562  xywindow.title("X-Y Plot " + SWRev + RevDate)
20563  xywindow.protocol("WM_DELETE_WINDOW", DestroyXYScreen)
20564  frame2xyr = Frame(xywindow, borderwidth=BorderSize, relief=FrameRefief)
20565  frame2xyr.pack(side=RIGHT, expand=NO, fill=BOTH)
20566 
20567  frame2xy = Frame(xywindow, borderwidth=BorderSize, relief=FrameRefief)
20568  frame2xy.pack(side=TOP, expand=YES, fill=BOTH)
20569 
20570  frame3xy = Frame(xywindow, borderwidth=BorderSize, relief=FrameRefief)
20571  frame3xy.pack(side=TOP, expand=NO, fill=BOTH)
20572 
20573  frame4xy = Frame(xywindow, borderwidth=BorderSize, relief=FrameRefief)
20574  frame4xy.pack(side=TOP, expand=NO, fill=BOTH)
20575 
20576  XYca = Canvas(frame2xy, width=CANVASwidthXY, height=CANVASheightXY, background=COLORcanvas, cursor='cross')
20577  XYca.bind('<Configure>', XYcaresize)
20578  XYca.bind('<1>', onCanvasXYLeftClick)
20579  XYca.bind('<3>', onCanvasXYRightClick)
20580  XYca.bind("<Motion>",onCanvasMouse_xy)
20581  XYca.bind('<MouseWheel>', onCanvasXYScrollClick)
20582  XYca.bind("<Button-4>", onCanvasXYScrollClick)# with Linux OS
20583  XYca.bind("<Button-5>", onCanvasXYScrollClick)
20584  XYca.bind("<Up>", onCanvasUpArrow)
20585  XYca.bind("<Down>", onCanvasDownArrow)
20586  XYca.bind("<Left>", onCanvasLeftArrow)
20587  XYca.bind("<Right>", onCanvasRightArrow)
20588  XYca.bind("<space>", onCanvasSpaceBar)
20589  XYca.bind("a", onCanvasAverage)
20590  XYca.pack(side=TOP, fill=BOTH, expand=YES)
20591  #
20592  RUNframe = Frame( frame2xyr )
20593  RUNframe.pack(side=TOP)
20594  rbxy = Button(RUNframe, text="Run", style="Run.TButton", command=BStart)
20595  rbxy.pack(side=LEFT)
20596  sbxy = Button(RUNframe, text="Stop", style="Stop.TButton", command=BStop)
20597  sbxy.pack(side=LEFT)
20598  # Open Math trace menu
20599  mathbt = Button(frame2xyr, text="Math", style="W5.TButton", command = NewEnterMathControls)
20600  mathbt.pack(side=TOP) #, anchor=W)
20601  # Disply mode menu
20602  # X - Y mode signal select
20603  AxisLabX = Label(frame2xyr, text ="-X Axis-", style="A10R1.TLabelframe.Label")
20604  AxisLabX.pack(side=TOP)
20605  chaxmenu = Frame( frame2xyr )
20606  chaxmenu.pack(side=TOP)
20607  rbx2 = Radiobutton(chaxmenu, text='CA-V', variable=Xsignal, value=1, command=UpdateXYTrace)
20608  rbx2.pack(side=LEFT, anchor=W)
20609  rbx3 = Radiobutton(chaxmenu, text='CA-I', variable=Xsignal, value=2, command=UpdateXYTrace)
20610  rbx3.pack(side=LEFT, anchor=W)
20611  chbxmenu = Frame( frame2xyr )
20612  chbxmenu.pack(side=TOP)
20613  rbx4 = Radiobutton(chbxmenu, text='CB-V', variable=Xsignal, value=3, command=UpdateXYTrace)
20614  rbx4.pack(side=LEFT, anchor=W)
20615  rbx5 = Radiobutton(chbxmenu, text='CB-I', variable=Xsignal, value=4, command=UpdateXYTrace)
20616  rbx5.pack(side=LEFT, anchor=W)
20617  rbx7 = Radiobutton(frame2xyr, text='Histogram CA-V', variable=Xsignal, value=6, command=BHistAsPercent)
20618  rbx7.pack(side=TOP)
20619  rbx8 = Radiobutton(frame2xyr, text='Histogram CB-V', variable=Xsignal, value=7, command=BHistAsPercent)
20620  rbx8.pack(side=TOP)
20621  rbx6 = Radiobutton(frame2xyr, text='Math', variable=Xsignal, value=5, command=UpdateXYTrace)
20622  rbx6.pack(side=TOP)
20623  #
20624  AxisLabY = Label(frame2xyr, text ="-Y Axis-", style="A10R2.TLabelframe.Label")
20625  AxisLabY.pack(side=TOP)
20626  chaymenu = Frame( frame2xyr )
20627  chaymenu.pack(side=TOP)
20628  rby2 = Checkbutton(chaymenu, text='CA-V', variable=YsignalVA, command=UpdateXYTrace)
20629  rby2.pack(side=LEFT, anchor=W)
20630  rby3 = Checkbutton(chaymenu, text='CA-I', variable=YsignalIA, command=UpdateXYTrace)
20631  rby3.pack(side=LEFT, anchor=W)
20632  chbymenu = Frame( frame2xyr )
20633  chbymenu.pack(side=TOP)
20634  rby4 = Checkbutton(chbymenu, text='CB-V', variable=YsignalVB, command=UpdateXYTrace)
20635  rby4.pack(side=LEFT, anchor=W)
20636  rby5 = Checkbutton(chbymenu, text='CB-I', variable=YsignalIB, command=UpdateXYTrace)
20637  rby5.pack(side=LEFT, anchor=W)
20638  rby7 = Checkbutton(frame2xyr, text='Math', variable=YsignalM, command=UpdateXYTrace)
20639  rby7.pack(side=TOP)
20640  mymenu = Frame( frame2xyr )
20641  mymenu.pack(side=TOP)
20642  rby7 = Checkbutton(mymenu, text='Math-X', variable=YsignalMX, command=UpdateXYTrace)
20643  rby7.pack(side=LEFT, anchor=W)
20644  rby8 = Checkbutton(mymenu, text='Math-Y', variable=YsignalMY, command=UpdateXYTrace)
20645  rby8.pack(side=LEFT, anchor=W)
20646  # show cursor menu buttons
20647  cursormenu = Frame( frame2xyr )
20648  cursormenu.pack(side=TOP)
20649  cb1 = Checkbutton(cursormenu, text='X-Cur', variable=ShowXCur)
20650  cb1.pack(side=LEFT, anchor=W)
20651  cb2 = Checkbutton(cursormenu, text='Y-Cur', variable=ShowYCur)
20652  cb2.pack(side=LEFT, anchor=W)
20653  cb4 = Checkbutton(frame2xyr, text='Persistance', variable=ScreenXYrefresh, command=UpdateXYTrace)
20654  cb4.pack(side=TOP)
20655  #
20656  # Reference trace menu
20657  XYrefmenu = Menubutton(frame2xyr, text="Ref Traces", style="W11.TButton")
20658  XYrefmenu.menu = Menu(XYrefmenu, tearoff = 0 )
20659  XYrefmenu["menu"] = XYrefmenu.menu
20660  XYrefmenu.menu.add_command(label="Save SnapShot", command=BSnapShotXY)
20661  XYrefmenu.menu.add_checkbutton(label="CA-V", variable=XYRefAV, command=UpdateXYTrace)
20662  XYrefmenu.menu.add_checkbutton(label="CA-I", variable=XYRefAI, command=UpdateXYTrace)
20663  XYrefmenu.menu.add_checkbutton(label="CB-V", variable=XYRefBV, command=UpdateXYTrace)
20664  XYrefmenu.menu.add_checkbutton(label="CB-I", variable=XYRefBI, command=UpdateXYTrace)
20665  XYrefmenu.menu.add_checkbutton(label="Math", variable=XYRefM, command=UpdateXYTrace)
20666  XYrefmenu.menu.add_checkbutton(label="Math-X", variable=XYRefMX, command=UpdateXYTrace)
20667  XYrefmenu.menu.add_checkbutton(label="Math-Y", variable=XYRefMY, command=UpdateXYTrace)
20668  XYrefmenu.pack(side=TOP) # , anchor=W)
20669 
20671  dismissxybutton = Button(frame2xyr, style="W7.TButton", text="Dismiss", command=DestroyXYScreen)
20672  dismissxybutton.pack(side=TOP)
20673  # Add a pair of user entry wigets
20674  if EnableUserEntries > 0:
20675  UserEnt = Frame( frame2xyr )
20676  UserEnt.pack(side=TOP)
20677  userentlab = Button(UserEnt, text="User", width=4, style="W4.TButton")
20678  userentlab.pack(side=LEFT,fill=X)
20679  User3Entry = Entry(UserEnt, width=5, cursor='double_arrow')
20680  User3Entry.bind('<Return>', onTextKey)
20681  User3Entry.bind('<MouseWheel>', onTextScroll)
20682  User3Entry.bind("<Button-4>", onTextScroll)# with Linux OS
20683  User3Entry.bind("<Button-5>", onTextScroll)
20684  User3Entry.bind('<Key>', onTextKey)
20685  User3Entry.pack(side=LEFT)
20686  User3Entry.delete(0,"end")
20687  User3Entry.insert(0,0.0)
20688  User4Entry = Entry(UserEnt, width=5, cursor='double_arrow')
20689  User4Entry.bind('<Return>', onTextKey)
20690  User4Entry.bind('<MouseWheel>', onTextScroll)
20691  User4Entry.bind("<Button-4>", onTextScroll)# with Linux OS
20692  User4Entry.bind("<Button-5>", onTextScroll)
20693  User4Entry.bind('<Key>', onTextKey)
20694  User4Entry.pack(side=LEFT)
20695  User4Entry.delete(0,"end")
20696  User4Entry.insert(0,0.0)
20697  #
20698  ADI1xy = Label(frame2xyr, image=logo, anchor= "sw", compound="top") # , height=49, width=116
20699  ADI1xy.pack(side=TOP)
20700  # Bottom Buttons
20701  MarkerXYScale = IntVar(0)
20702  MarkerXYScale.set(1)
20703  # Voltage channel A
20704  CHAsbxy = Spinbox(frame3xy, width=4, cursor='double_arrow', values=CHvpdiv)
20705  CHAsbxy.bind('<MouseWheel>', onSpinBoxScroll)
20706  CHAsbxy.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
20707  CHAsbxy.bind("<Button-5>", onSpinBoxScroll)
20708  CHAsbxy.pack(side=LEFT)
20709  CHAsbxy.delete(0,"end")
20710  CHAsbxy.insert(0,0.5)
20711  CHAxylab = Button(frame3xy, text="CA V/Div", style="Rtrace1.TButton", command=SetXYScaleA)
20712  CHAxylab.pack(side=LEFT)
20713 
20714  CHAVPosEntryxy = Entry(frame3xy, width=5, cursor='double_arrow')
20715  CHAVPosEntryxy.bind('<Return>', onTextKey)
20716  CHAVPosEntryxy.bind('<MouseWheel>', onTextScroll)
20717  CHAVPosEntryxy.bind("<Button-4>", onTextScroll)# with Linux OS
20718  CHAVPosEntryxy.bind("<Button-5>", onTextScroll)
20719  CHAVPosEntryxy.bind('<Key>', onTextKey)
20720  CHAVPosEntryxy.pack(side=LEFT)
20721  CHAVPosEntryxy.delete(0,"end")
20722  CHAVPosEntryxy.insert(0,2.5)
20723  CHAofflabxy = Button(frame3xy, text="CA V Pos", style="Rtrace1.TButton", command=SetXYVAPoss)
20724  CHAofflabxy.pack(side=LEFT)
20725  # Current channel A
20726  CHAIsbxy = Spinbox(frame3xy, width=4, cursor='double_arrow', values=CHipdiv)
20727  CHAIsbxy.bind('<MouseWheel>', onSpinBoxScroll)
20728  CHAIsbxy.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
20729  CHAIsbxy.bind("<Button-5>", onSpinBoxScroll)
20730  CHAIsbxy.pack(side=LEFT)
20731  CHAIsbxy.delete(0,"end")
20732  CHAIsbxy.insert(0,50.0)
20733  CHAIlabxy = Label(frame3xy, text="CA mA/Div", style="Strace3.TButton")
20734  CHAIlabxy.pack(side=LEFT)
20735 
20736  CHAIPosEntryxy = Entry(frame3xy, width=5, cursor='double_arrow')
20737  CHAIPosEntryxy.bind('<Return>', onTextKey)
20738  CHAIPosEntryxy.bind('<MouseWheel>', onTextScroll)
20739  CHAIPosEntryxy.bind("<Button-4>", onTextScroll)# with Linux OS
20740  CHAIPosEntryxy.bind("<Button-5>", onTextScroll)
20741  CHAIPosEntryxy.bind('<Key>', onTextKey)
20742  CHAIPosEntryxy.pack(side=LEFT)
20743  CHAIPosEntryxy.delete(0,"end")
20744  CHAIPosEntryxy.insert(0,0.0)
20745  CHAIofflabxy = Button(frame3xy, text="CA I Pos", style="Rtrace3.TButton", command=SetXYIAPoss)
20746  CHAIofflabxy.pack(side=LEFT)
20747  # Voltage channel B
20748  CHBsbxy = Spinbox(frame4xy, width=4, cursor='double_arrow', values=CHvpdiv)
20749  CHBsbxy.bind('<MouseWheel>', onSpinBoxScroll)
20750  CHBsbxy.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
20751  CHBsbxy.bind("<Button-5>", onSpinBoxScroll)
20752  CHBsbxy.pack(side=LEFT)
20753  CHBsbxy.delete(0,"end")
20754  CHBsbxy.insert(0,0.5)
20755  #
20756  CHBxylab = Button(frame4xy, text="CB V/Div", style="Strace2.TButton", command=SetXYScaleB)
20757  CHBxylab.pack(side=LEFT)
20758 
20759  CHBVPosEntryxy = Entry(frame4xy, width=5, cursor='double_arrow')
20760  CHBVPosEntryxy.bind('<Return>', onTextKey)
20761  CHBVPosEntryxy.bind('<MouseWheel>', onTextScroll)
20762  CHBVPosEntryxy.bind("<Button-4>", onTextScroll)# with Linux OS
20763  CHBVPosEntryxy.bind("<Button-5>", onTextScroll)
20764  CHBVPosEntryxy.bind('<Key>', onTextKey)
20765  CHBVPosEntryxy.pack(side=LEFT)
20766  CHBVPosEntryxy.delete(0,"end")
20767  CHBVPosEntryxy.insert(0,2.5)
20768  CHBofflabxy = Button(frame4xy, text="CB V Pos", style="Rtrace2.TButton", command=SetXYVBPoss)
20769  CHBofflabxy.pack(side=LEFT)
20770  # Current channel B
20771  CHBIsbxy = Spinbox(frame4xy, width=4, cursor='double_arrow', values=CHipdiv) #
20772  CHBIsbxy.bind('<MouseWheel>', onSpinBoxScroll)
20773  CHBIsbxy.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
20774  CHBIsbxy.bind("<Button-5>", onSpinBoxScroll)
20775  CHBIsbxy.pack(side=LEFT)
20776  CHBIsbxy.delete(0,"end")
20777  CHBIsbxy.insert(0,50.0)
20778  CHBIlabxy = Label(frame4xy, text="CB mA/Div", style="Strace4.TButton")
20779  CHBIlabxy.pack(side=LEFT)
20780 
20781  CHBIPosEntryxy = Entry(frame4xy, width=5, cursor='double_arrow')
20782  CHBIPosEntryxy.bind('<Return>', onTextKey)
20783  CHBIPosEntryxy.bind('<MouseWheel>', onTextScroll)
20784  CHBIPosEntryxy.bind("<Button-4>", onTextScroll)# with Linux OS
20785  CHBIPosEntryxy.bind("<Button-5>", onTextScroll)
20786  CHBIPosEntryxy.bind('<Key>', onTextKey)
20787  CHBIPosEntryxy.pack(side=LEFT)
20788  CHBIPosEntryxy.delete(0,"end")
20789  CHBIPosEntryxy.insert(0,0.0)
20790  CHBIofflabxy = Button(frame4xy, text="CB I Pos", style="Rtrace4.TButton", command=SetXYIBPoss)
20791  CHBIofflabxy.pack(side=LEFT)
20792  #
20793  if ShowBallonHelp > 0:
20794  #xb1_tip = CreateToolTip(xb1, 'Enter formula for X axis Math trace')
20795  #xb2_tip = CreateToolTip(xb2, 'Enter which axis controls to use for X axis Math trace')
20796  #yb1_tip = CreateToolTip(yb1, 'Enter formula for Y axis Math trace')
20797  #yb2_tip = CreateToolTip(yb2, 'Enter which axis controls to use for Y axis Math trace')
20798  math_tip = CreateToolTip(mathbt, 'Open Math window')
20799  bsxy_tip = CreateToolTip(sbxy, 'Stop acquiring data')
20800  brxy_tip = CreateToolTip(rbxy, 'Start acquiring data')
20801  #snapbutton_tip = CreateToolTip(snapbutton, 'Take snap shot of current trace')
20802  #savebutton_tip = CreateToolTip(savebutton, 'Save current trace to EPS file')
20803  dismissxybutton_tip = CreateToolTip(dismissxybutton, 'Diamiss X-Y plot window')
20804  CHAxylab_tip = CreateToolTip(CHAxylab, 'Select CHA-V vertical range/position axis to be used for markers and drawn color')
20805  CHBxylab_tip = CreateToolTip(CHBxylab, 'Select CHB-V vertical range/position axis to be used for markers and drawn color')
20806  CHAxyofflab_tip = CreateToolTip(CHAofflabxy, 'Set CHA-V position to DC average of signal')
20807  CHBxyofflab_tip = CreateToolTip(CHBofflabxy, 'Set CHB-V position to DC average of signal')
20808  CHAIxyofflab_tip = CreateToolTip(CHAIofflabxy, 'Set CHA-I position to DC average of signal')
20809  CHBIxyofflab_tip = CreateToolTip(CHBIofflabxy, 'Set CHB-I position to DC average of signal')
20810  if LocalLanguage != "English":
20811  BLoadConfig(LocalLanguage)
20812 
20813 def DestroyXYScreen():
20814  global xywindow, XYScreenStatus, ca, XYDisp
20815 
20816  XYScreenStatus.set(0)
20817  XYDisp.set(0)
20818  XYCheckBox()
20819  xywindow.destroy()
20820  ca.bind_all('<MouseWheel>', onCanvasClickScroll)
20821 #
20822 # Optional Calibration procedure routine
20823 #
20824 def SelfCalibration():
20825  global DevID, devx, CHA, CHB, RevDate, OnBoardRes, AD584act, FWRevOne
20826  global discontloop, contloop, session, AWGSync, SWRev
20827  # global OnBoardResAgnd, OnBoardResA25, OnBoardResBgnd, OnBoardResB25
20828  # setup cal results window
20829  if FWRevOne < 2.06: # Check firmware revision level > 2.06
20830  showwarning("WARNING","Out of date Firmware Revision!")
20831  return
20832  calwindow = Toplevel()
20833  calwindow.title("ALM1000 Calibration tool " + SWRev + RevDate)
20834  # display wigets
20835  SCallab = Label(calwindow, text="Channel Gain / Offset calibration")
20836  SCallab.grid(row=0, column=0, columnspan=2, sticky=W)
20837  labelA0 = Label(calwindow, style="A12B.TLabel")
20838  labelA0.grid(row=1, column=0, columnspan=2, sticky=W)
20839  labelA0.config(text = "CA gnd Volts")
20840  labelAMax = Label(calwindow, style="A12B.TLabel")
20841  labelAMax.grid(row=2, column=0, columnspan=2, sticky=W)
20842  labelAMax.config(text = "CA 584 Volts")
20843  labelAMin = Label(calwindow, style="A12B.TLabel")
20844  labelAMin.grid(row=3, column=0, columnspan=2, sticky=W)
20845  labelAMin.config(text = "CA 5V Src I ")
20846  labelB0 = Label(calwindow, style="A12B.TLabel")
20847  labelB0.grid(row=4, column=0, columnspan=2, sticky=W)
20848  labelB0.config(text = "CA gnd Volts")
20849  labelBMax = Label(calwindow, style="A12B.TLabel")
20850  labelBMax.grid(row=5, column=0, columnspan=2, sticky=W)
20851  labelBMax.config(text = "CB 584 Volts")
20852  labelBMin = Label(calwindow, style="A12B.TLabel")
20853  labelBMin.grid(row=6, column=0, columnspan=2, sticky=W)
20854  labelBMin.config(text = "CB 5V Src I ")
20855  labelAB = Label(calwindow, style="A12B.TLabel")
20856  labelAB.grid(row=7, column=0, columnspan=2, sticky=W)
20857  labelAB.config(text = "CA 0V Src I")
20858  labelBA = Label(calwindow, style="A12B.TLabel")
20859  labelBA.grid(row=8, column=0, columnspan=2, sticky=W)
20860  labelBA.config(text = "CA 0V Src I")
20861  labelSIA0 = Label(calwindow, style="A12B.TLabel")
20862  labelSIA0.grid(row=9, column=0, columnspan=2, sticky=W)
20863  labelSIA0.config(text = "CA 2.5 Src 0 I")
20864  labelSIA = Label(calwindow, style="A12B.TLabel")
20865  labelSIA.grid(row=10, column=0, columnspan=2, sticky=W)
20866  labelSIA.config(text = "CA 50 Src 100 ")
20867  labelSIAN = Label(calwindow, style="A12B.TLabel")
20868  labelSIAN.grid(row=11, column=0, columnspan=2, sticky=W)
20869  labelSIAN.config(text = "CA 50 Src -45")
20870  labelSIB0 = Label(calwindow, style="A12B.TLabel")
20871  labelSIB0.grid(row=12, column=0, columnspan=2, sticky=W)
20872  labelSIB0.config(text = "CB 2.5 Src 0 I")
20873  labelSIB = Label(calwindow, style="A12B.TLabel")
20874  labelSIB.grid(row=13, column=0, columnspan=2, sticky=W)
20875  labelSIB.config(text = "CB 50 Src 100 ")
20876  labelSIBN = Label(calwindow, style="A12B.TLabel")
20877  labelSIBN.grid(row=14, column=0, columnspan=2, sticky=W)
20878  labelSIBN.config(text = "CB 50 Src -45")
20879  # set to default mux and dac settings
20880  devx.ctrl_transfer(0x40, 0x24, 0x0, 0, 0, 0, 100) # set to addr DAC A
20881  devx.ctrl_transfer(0x40, 0x25, 0x1, 0, 0, 0, 100) # set to addr DAC B
20882  AWGSync.set(1)
20883  BAWGSync()
20884  if session.continuous:
20885  print( "ending session")
20886  session.end()
20887  # Setup ADALM1000
20888  if askyesno("Reset Calibration", "Do You Need To Reset Default Calibration?", parent=calwindow):
20889  #print(devx.calibration)
20890  try:
20891  devx.write_calibration("calib_default.txt")
20892  #print "wrote calib_default.txt"
20893  except:
20894  filename = askopenfilename(defaultextension = ".txt", filetypes=[("Default Cal File", "*.txt")], parent=calwindow)
20895  devx.write_calibration(filename)
20896  #print(devx.calibration)
20897  #
20898  devidstr = DevID[17:31]
20899  filename = "calib" + devidstr + ".txt"
20900  if os.path.isfile(filename):
20901  if askyesno("Calibration exists", "A previous Calibration file exists. /n Do you want to load that?", parent=calwindow):
20902  devx.write_calibration(filename)
20903  #print "wrote old ", filename
20904  calwindow.destroy()
20905  return
20906  else:
20907  if askyesno("Continue?", "Continure with self calibration?", parent=calwindow):
20908  donothing()
20909  else:
20910  calwindow.destroy()
20911  return
20912  #
20913  CalFile = open(filename, "w")
20914  #
20915  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
20916  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
20917  devx.ctrl_transfer( 0x40, 0x50, 34, 0, 0, 0, 100) # close voltage sense loop just in case
20918  devx.ctrl_transfer( 0x40, 0x50, 39, 0, 0, 0, 100) # close voltage sense loop just in case
20919  ADsignal1 = [] # Ain signal array channel
20920  ADsignal1 = devx.get_samples(1010)
20921  # Pause whie user connects external voltage reference AD584
20922  BadData = 1
20923  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
20924  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
20925  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
20926  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
20927  RequestVRef = askstring("External Reference", "Enter External Reference Voltage", initialvalue=AD584act, parent=root)
20928  try:
20929  AD584act = float(RequestVRef)*1.0
20930  except:
20931  AD584act = 3.3
20932  showinfo("CONNECT","Connect External Voltage to both CHA and CHB inputs.", parent=calwindow)
20933  while (BadData): # loop till good reading
20934  # Get A and B AD584 data
20935  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
20936  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
20937  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
20938  CHA584Raw = CHB584Raw = 0.0 # initalize measurment variable
20939  # get_samples returns a list of values for voltage [0] and current [1]
20940  for index in range(1000): # calculate average
20941  CHA584Raw += ADsignal1[index+10][0][0] # Sum for average CA voltage
20942  CHB584Raw += ADsignal1[index+10][1][0] # Sum for average CB voltage
20943 
20944  CHA584Raw = CHA584Raw / 1000.0 # calculate average
20945  CHB584Raw = CHB584Raw / 1000.0 # calculate average
20946  VString = "Extern A Volts " + ' {0:.4f} '.format(CHA584Raw) # format with 4 decimal places
20947  labelAMax.config(text = VString) # change displayed value
20948  VString = "Extern B Volts " + ' {0:.4f} '.format(CHB584Raw) # format with 4 decimal places
20949  labelBMax.config(text = VString) # change displayed value
20950  Lower = AD584act - 0.3
20951  Upper = AD584act + 0.3
20952  if CHA584Raw < Lower or CHA584Raw > Upper or CHB584Raw < Lower or CHB584Raw > Upper:
20953  if askyesno("CONNECT","Did not get good data from Ref V check connections!\n Abort(Y) or Try again(N)", parent=calwindow):
20954  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
20955  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
20956  contloop = 0
20957  discontloop = 1
20958  calwindow.destroy()
20959  return
20960  else:
20961  BadData = 0
20962  #
20963  showinfo("DISCONNECT","Disconnect everything from CHA and CHB pins.", parent=calwindow)
20964  CHAGndRaw = CHBGndRaw = CHAI0gRaw = CHBI0gRaw = 0.0 # initalize measurment variable
20965  # Get A GND and B GND data
20966  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
20967  devx.ctrl_transfer(0x40, 0x50, 33, 0, 0, 0, 100) # set GND switch to closed
20968  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
20969  devx.ctrl_transfer(0x40, 0x50, 38, 0, 0, 0, 100) # set CHB GND switch to closed
20970  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
20971  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
20972  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
20973  # get_samples returns a list of values for voltage [0] and current [1]
20974  for index in range(1000): # calculate average
20975  CHAGndRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
20976  CHBGndRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
20977  CHAI0gRaw += ADsignal1[index+10][0][1] # Sum for average CA current
20978  CHBI0gRaw += ADsignal1[index+10][1][1] # Sum for average CB current
20979 
20980  CHAGndRaw = CHAGndRaw / 1000.0 # calculate average
20981  CHAI0gRaw = CHAI0gRaw / 1000.0
20982  CHBGndRaw = CHBGndRaw / 1000.0 # calculate average
20983  CHBI0gRaw = CHBI0gRaw / 1000.0
20984  VString = "CA gnd Volts " + ' {0:.4f} '.format(CHAGndRaw) # format with 4 decimal places
20985  labelA0.config(text = VString) # change displayed value
20986  VString = "CB gnd Volts " + ' {0:.4f} '.format(CHBGndRaw) # format with 4 decimal places
20987  labelB0.config(text = VString) # change displayed value
20988  CHA2p5Raw = CHB2p5Raw = CHAI02p5Raw = CHBI02p5Raw = 0.0 # initalize measurment variable
20989  # Get A and B data for internal 2.5 rail
20990  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
20991  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
20992  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set 2.5 V switch to closed
20993  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
20994  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
20995  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
20996  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
20997  # get_samples returns a list of values for voltage [0] and current [1]
20998  for index in range(1000): # calculate average
20999  CHA2p5Raw += ADsignal1[index+10][0][0] # Sum for average CA voltage
21000  CHB2p5Raw += ADsignal1[index+10][1][0] # Sum for average CB voltage
21001  CHAI02p5Raw += ADsignal1[index+10][0][1] # Sum for average CA current
21002  CHBI02p5Raw += ADsignal1[index+10][1][1] # Sum for average CB current
21003 
21004  CHA2p5Raw = CHA2p5Raw / 1000.0 # calculate average
21005  CHAI02p5Raw = CHAI02p5Raw / 1000.0
21006  CHB2p5Raw = CHB2p5Raw / 1000.0 # calculate average
21007  CHBI02p5Raw = CHBI02p5Raw / 1000.0
21008  # Get A force 0V and B force 0V data
21009  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
21010  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
21011  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
21012  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
21013  CHA.mode = Mode.SVMI
21014  CHA.constant(0.0)
21015  CHB.mode = Mode.SVMI
21016  CHB.constant(0.0)
21017  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
21018  CHAF0vRaw = CHBF0vRaw = CHAI0F0Raw = CHBI0F0Raw = 0.0 # initalize measurment variable
21019  # get_samples returns a list of values for voltage [0] and current [1]
21020  for index in range(1000): # calculate average
21021  CHAF0vRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
21022  CHBF0vRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
21023  CHAI0F0Raw += ADsignal1[index+10][0][1] # Sum for average CA current
21024  CHBI0F0Raw += ADsignal1[index+10][1][1] # Sum for average CB current
21025 
21026  CHAF0vRaw = CHAF0vRaw / 1000.0 # calculate average
21027  CHAI0F0Raw = CHAI0F0Raw / 1000.0
21028  CHBF0vRaw = CHBF0vRaw / 1000.0 # calculate average
21029  CHBI0F0Raw = CHBI0F0Raw / 1000.0
21030  # Get A force 2.5V and B force 2.5V data
21031  CHA.mode = Mode.SVMI
21032  CHA.constant(4.5)
21033  CHB.mode = Mode.SVMI
21034  CHB.constant(4.5)
21035  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
21036  CHAF25vRaw = CHAI0F25Raw = CHBF25vRaw = CHBI0F25Raw = 0.0 # initalize measurment variable
21037  # get_samples returns a list of values for voltage [0] and current [1]
21038  for index in range(1000): # calculate average
21039  CHAF25vRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
21040  CHBF25vRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
21041  CHAI0F25Raw += ADsignal1[index+10][0][1] # Sum for average CA current
21042  CHBI0F25Raw += ADsignal1[index+10][1][1] # Sum for average CB current
21043 
21044  CHAF25vRaw = CHAF25vRaw / 1000.0 # calculate average
21045  CHAI0F25Raw = CHAI0F25Raw / 1000.0
21046  CHBF25vRaw = CHBF25vRaw / 1000.0 # calculate average
21047  CHBI0F25Raw = CHBI0F25Raw / 1000.0
21048  #
21049  # Get A and B measure current data for int 50 res to gnd at 5V
21050  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
21051  devx.ctrl_transfer(0x40, 0x50, 33, 0, 0, 0, 100) # set CHA GND switch to closed
21052  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
21053  devx.ctrl_transfer(0x40, 0x50, 38, 0, 0, 0, 100) # set CHB GND switch to closed
21054  CHA.mode = Mode.SVMI
21055  CHA.constant(5.0)
21056  CHB.mode = Mode.SVMI
21057  CHB.constant(5.0)
21058  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
21059  CHASr5vRaw = CHAISr5vRaw = CHBSr5vRaw = CHBISr5vRaw = 0.0 # initalize measurment variable
21060  for index in range(1000): # calculate average
21061  CHASr5vRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
21062  CHBSr5vRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
21063  CHAISr5vRaw += ADsignal1[index+10][0][1] # Sum for average CA current
21064  CHBISr5vRaw += ADsignal1[index+10][1][1] # Sum for average CB current
21065 
21066  CHASr5vRaw = CHASr5vRaw / 1000.0 # calculate average
21067  CHAISr5vRaw = CHAISr5vRaw / 1000.0
21068  CHBSr5vRaw = CHBSr5vRaw / 1000.0 # calculate average
21069  CHBISr5vRaw = CHBISr5vRaw / 1000.0
21070  VString = "CA 5V Src I " + ' {0:.4f} '.format(CHAISr5vRaw) # format with 4 decimal places
21071  labelAMin.config(text = VString) # change displayed value
21072  VString = "CB 5V Src I " + ' {0:.4f} '.format(CHBISr5vRaw) # format with 4 decimal places
21073  labelBMin.config(text = VString) # change displayed value
21074  # Get A and B measure current data for int 50 res to 2.5 V at 0V
21075  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to closed
21076  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
21077  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
21078  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
21079  CHA.mode = Mode.SVMI
21080  CHA.constant(0.001)
21081  CHB.mode = Mode.SVMI
21082  CHB.constant(0.001)
21083  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
21084  CHASr0vRaw = CHAISr0vRaw = CHBSr0vRaw = CHBISr0vRaw = 0.0 # initalize measurment variable
21085  for index in range(1000): # calculate average
21086  CHASr0vRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
21087  CHBSr0vRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
21088  CHAISr0vRaw += ADsignal1[index+10][0][1] # Sum for average CA current
21089  CHBISr0vRaw += ADsignal1[index+10][1][1] # Sum for average CB current
21090 
21091  CHASr0vRaw = CHASr0vRaw / 1000.0 # calculate average
21092  CHAISr0vRaw = CHAISr0vRaw / 1000.0
21093  CHBSr0vRaw = CHBSr0vRaw / 1000.0 # calculate average
21094  CHBISr0vRaw = CHBISr0vRaw / 1000.0
21095  VString = "CA 0V Src I " + ' {0:.4f} '.format(CHAISr0vRaw) # format with 4 decimal places
21096  labelAB.config(text = VString) # change displayed value
21097  VString = "CB 0V Src I " + ' {0:.4f} '.format(CHBISr0vRaw) # format with 4 decimal places
21098  labelBA.config(text = VString) # change displayed value
21099 
21100  # Get A and B force 0.0 current data for int 50 res to 2.5 rail
21101  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to closed
21102  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
21103  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
21104  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
21105  CHA.mode = Mode.SIMV
21106  CHA.constant(0.0)
21107  CHB.mode = Mode.SIMV
21108  CHB.constant(0.0)
21109  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
21110  CHAVSr0iRaw = CHAISr0iRaw = CHBVSr0iRaw = CHBISr0iRaw = 0.0 # initalize measurment variable
21111  for index in range(1000): # calculate average
21112  CHAVSr0iRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
21113  CHBVSr0iRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
21114  CHAISr0iRaw += ADsignal1[index+10][0][1] # Sum for average CA current
21115  CHBISr0iRaw += ADsignal1[index+10][1][1] # Sum for average CB current
21116 
21117  CHAVSr0iRaw = CHAVSr0iRaw / 1000.0 # calculate average
21118  CHAISr0iRaw = CHAISr0iRaw / 1000.0
21119  CHBVSr0iRaw = CHBVSr0iRaw / 1000.0 # calculate average
21120  CHBISr0iRaw = CHBISr0iRaw / 1000.0
21121  VString = "CA 2.5 Src 0 I" + ' {0:.4f} '.format(CHAISr0iRaw) # format with 4 decimal places
21122  labelSIA0.config(text = VString) # change displayed value
21123  VString = "CB 2.5 Src 0 I" + ' {0:.4f} '.format(CHBISr0iRaw) # format with 4 decimal places
21124  labelSIB0.config(text = VString) # change displayed value
21125  #
21126  # Get A and B force +0.45 current data for int 50 res to 2.5 V rail
21127  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to closed
21128  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
21129  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
21130  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
21131  CHA.mode = Mode.SIMV
21132  CHA.constant(0.045)
21133  CHB.mode = Mode.SIMV
21134  CHB.constant(0.045)
21135  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
21136  CHAVSr100Raw = CHAISr100Raw = CHBVSr100Raw = CHBISr100Raw = 0.0 # initalize measurment variable
21137  for index in range(1000): # calculate average
21138  CHAVSr100Raw += ADsignal1[index+10][0][0] # Sum for average CA voltage
21139  CHBVSr100Raw += ADsignal1[index+10][1][0] # Sum for average CB voltage
21140  CHAISr100Raw += ADsignal1[index+10][0][1] # Sum for average CA current
21141  CHBISr100Raw += ADsignal1[index+10][1][1] # Sum for average CB current
21142 
21143  CHAVSr100Raw = CHAVSr100Raw / 1000.0 # calculate average
21144  CHAISr100Raw = CHAISr100Raw / 1000.0
21145  CHBVSr100Raw = CHBVSr100Raw / 1000.0 # calculate average
21146  CHBISr100Raw = CHBISr100Raw / 1000.0
21147  VString = "CA 50 Src +45 " + ' {0:.4f} '.format(CHAVSr100Raw) # format with 4 decimal places
21148  labelSIA.config(text = VString) # change displayed value
21149  VString = "CB 50 Src +45 " + ' {0:.4f} '.format(CHBVSr100Raw) # format with 4 decimal places
21150  labelSIB.config(text = VString) # change displayed value
21151  #
21152  # Get A and B force -0.045 current data for int 50 res to 2.5 V rail
21153  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to closed
21154  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
21155  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
21156  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
21157  CHA.mode = Mode.SIMV
21158  CHA.constant(-0.045)
21159  CHB.mode = Mode.SIMV
21160  CHB.constant(-0.045)
21161  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
21162  CHAVSrN45Raw = CHAISrN45Raw = CHBVSrN45Raw = CHBISrN45Raw = 0.0 # initalize measurment variable
21163  for index in range(1000): # calculate average
21164  CHAVSrN45Raw += ADsignal1[index+10][0][0] # Sum for average CA voltage
21165  CHBVSrN45Raw += ADsignal1[index+10][1][0] # Sum for average CB voltage
21166  CHAISrN45Raw += ADsignal1[index+10][0][1] # Sum for average CA current
21167  CHBISrN45Raw += ADsignal1[index+10][1][1] # Sum for average CB current
21168 
21169  CHAVSrN45Raw = CHAVSrN45Raw / 1000.0 # calculate average
21170  CHAISrN45Raw = CHAISrN45Raw / 1000.0
21171  CHBVSrN45Raw = CHBVSrN45Raw / 1000.0 # calculate average
21172  CHBISrN45Raw = CHBISrN45Raw / 1000.0
21173  VString = "CA 50 Src -45 " + ' {0:.4f} '.format(CHAVSrN45Raw) # format with 4 decimal places
21174  labelSIAN.config(text = VString) # change displayed value
21175  VString = "CB 50 Src -45 " + ' {0:.4f} '.format(CHBVSrN45Raw) # format with 4 decimal places
21176  labelSIBN.config(text = VString) # change displayed value
21177  # return all switches to open
21178  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
21179  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
21180  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
21181  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
21182  # Caculate voltage gain errors
21183  #
21184  CHAF25V = CHAF25vRaw * ( AD584act / CHA584Raw )
21185  CHBF25V = CHBF25vRaw * ( AD584act / CHB584Raw )
21186  #
21187  CHASr5v = CHASr5vRaw * ( AD584act / CHA584Raw ) # calculate actual voltage
21188  CHBSr5v = CHBSr5vRaw * ( AD584act / CHB584Raw ) # calculate actual voltage
21189  #
21190  CHA2p5 = CHA2p5Raw * ( AD584act / CHA584Raw )
21191  # print "calculated fixed 2.5 from CHA ", CHA2p5
21192  CHB2p5 = CHB2p5Raw * ( AD584act / CHB584Raw )
21193  # print "calculated fixed 2.5 from CHB ", CHB2p5
21194  #
21195  CHAActSrI = CHASr5v / OnBoardRes # adjust resistor value to include switch ron
21196  CHBActSrI = CHBSr5v / OnBoardRes # adjust resistor value to include switch ron
21197  #
21198  CHAActSnkI = CHASr0vRaw - CHA2p5 / OnBoardRes # adjust resistor value to include switch ron
21199  CHBActSnkI = CHBSr0vRaw - CHB2p5 / OnBoardRes # adjust resistor value to include switch ron
21200  #
21201  CHASr0i = CHAVSr0iRaw * ( AD584act / CHA584Raw )
21202  CHASr0iAct = CHASr0i / OnBoardRes # adjust resistor value to include switch ron
21203  CHASr100 = CHAVSr100Raw * ( AD584act / CHA584Raw )
21204  CHASrI100Act = (CHASr100 - CHA2p5) / OnBoardRes # adjust resistor value to include switch ron
21205  CHASrN45 = CHAVSrN45Raw * ( AD584act / CHA584Raw )
21206  CHASrIN45Act = (CHASrN45 - CHA2p5) / OnBoardRes # adjust resistor value to include switch ron
21207  #
21208  CHBSr0i = CHBVSr0iRaw * ( AD584act / CHB584Raw )
21209  CHBSr0iAct = CHBSr0i / OnBoardRes # adjust resistor value to include switch ron
21210  CHBSr100 = CHBVSr100Raw * ( AD584act / CHB584Raw )
21211  CHBSrI100Act = (CHBSr100 - CHB2p5) / OnBoardRes # adjust resistor value to include switch ron
21212  CHBSrN45 = CHBVSrN45Raw * ( AD584act / CHB584Raw )
21213  CHBSrIN45Act = (CHBSrN45 - CHB2p5) / OnBoardRes # adjust resistor value to include switch ron
21214  # Write cal factors to file
21215  #
21216  CalFile.write('# Channel A, measure V\n')
21217  CalFile.write('</>\n')
21218  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHAGndRaw) + '>\n')
21219  CalFile.write('<' + '{0:.4f}'.format(AD584act) + ', ' + '{0:.4f}'.format(CHA584Raw) + '>\n')
21220  CalFile.write('<>\n')
21221  CalFile.write('\n')
21222  #
21223  CalFile.write('# Channel A, measure I\n')
21224  CalFile.write('</>\n')
21225  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHAI02p5Raw) + '>\n')
21226  CalFile.write('<' + '{0:.4f}'.format(CHAActSrI) + ', ' + '{0:.4f}'.format(CHAISr5vRaw) + '>\n')
21227  # CalFile.write('<' + '{0:.4f}'.format(CHAISr0vRaw) + ', ' + '{0:.4f}'.format(CHAActSnkI) + '>\n')
21228  CalFile.write('<' + '{0:.4f}'.format(-CHAActSrI) + ', ' + '{0:.4f}'.format(-CHAISr5vRaw) + '>\n')
21229  CalFile.write('<>\n')
21230  CalFile.write('\n')
21231  #
21232  CalFile.write('# Channel A, source V\n')
21233  CalFile.write('</>\n')
21234  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHAF0vRaw) + '>\n')
21235  CalFile.write('<4.5000, ' + '{0:.4f}'.format(CHAF25V) + '>\n')
21236  CalFile.write('<>\n')
21237  CalFile.write('\n')
21238  #
21239  CalFile.write('# Channel A, source I\n')
21240  CalFile.write('</>\n')
21241  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHAISr0iRaw) + '>\n')
21242  CalFile.write('<0.045, ' + '{0:.4f}'.format(CHASrI100Act) + '>\n')
21243  CalFile.write('<-0.0450, ' + '{0:.4f}'.format(CHASrIN45Act) + '>\n')
21244  CalFile.write('<>\n')
21245  CalFile.write('\n')
21246  #
21247  CalFile.write('# Channel B, measure V\n')
21248  CalFile.write('</>\n')
21249  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHBGndRaw) + '>\n')
21250  CalFile.write('<' + '{0:.4f}'.format(AD584act) + ', ' + '{0:.4f}'.format(CHB584Raw) + '>\n')
21251  CalFile.write('<>\n')
21252  CalFile.write('\n')
21253  #
21254  CalFile.write('# Channel B, measure I\n')
21255  CalFile.write('</>\n')
21256  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHBI02p5Raw) + '>\n')
21257  CalFile.write('<' + '{0:.4f}'.format(CHBActSrI) + ', ' + '{0:.4f}'.format(CHBISr5vRaw) + '>\n')
21258  # CalFile.write('<' + '{0:.4f}'.format(CHBISr0vRaw) + ', ' + '{0:.4f}'.format(CHBActSnkI) + '>\n')
21259  CalFile.write('<' + '{0:.4f}'.format(-CHBActSrI) + ', ' + '{0:.4f}'.format(-CHBISr5vRaw) + '>\n')
21260  CalFile.write('<>\n')
21261  CalFile.write('\n')
21262  #
21263  CalFile.write('# Channel B, source V\n')
21264  CalFile.write('</>\n')
21265  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHBF0vRaw) + '>\n')
21266  CalFile.write('<4.5000, ' + '{0:.4f}'.format(CHAF25V) + '>\n')
21267  CalFile.write('<>\n')
21268  CalFile.write('\n')
21269  #
21270  CalFile.write('# Channel B source I\n')
21271  CalFile.write('</>\n')
21272  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHBISr0iRaw) + '>\n')
21273  CalFile.write('<0.045, ' + '{0:.4f}'.format(CHBSrI100Act) + '>\n')
21274  CalFile.write('<-0.0450, ' + '{0:.4f}'.format(CHBSrIN45Act) + '>\n')
21275  CalFile.write('<>\n')
21276  #
21277  CalFile.close()
21278  showinfo("Finish","Successfully measured cal factors!", parent=calwindow)
21279  if askyesno("Write cal", "Write Cal Data to Board?", parent=calwindow):
21280  devx.write_calibration(filename)
21281  #print "wrote new " , filename
21282  #
21283  # session.end()
21284  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
21285  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
21286  contloop = 0
21287  discontloop = 1
21288  # session.cancel()
21289  calwindow.destroy()
21290 #
21291 def Save_Cal_file():
21292  global cal, DevID, devx
21293 
21294  devidstr = DevID[17:31]
21295  filename = "calib" + devidstr + "test.txt"
21296  if os.path.isfile(filename):
21297  if askyesno("Calibration exists", "A previous Calibration file exists. /n Do you want to load that?"): #, parent=calwindow):
21298  return
21299  else:
21300  if askyesno("Continue?", "Continure with save calibration file?"): #, parent=calwindow):
21301  donothing()
21302  else:
21303  calwindow.destroy()
21304  return
21305  #
21306  CalFile = open(filename, "w")
21307  #
21308  # Write cal factors to file
21309  # [0]
21310  CalFile.write('# Channel A, measure V\n')
21311  CalFile.write('</>\n')
21312  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[0][0]) + '>\n')
21313  CHAgp = (5.0/cal[0][1])+cal[0][0]
21314  CalFile.write('<5.0000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
21315  CalFile.write('<>\n')
21316  CalFile.write('\n')
21317  # [1]
21318  CalFile.write('# Channel A, measure I\n')
21319  CalFile.write('</>\n')
21320  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[1][0]) + '>\n')
21321  CHAgp = (0.1/cal[0][1])+cal[1][0]
21322  CalFile.write('<0.1000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
21323  CHAgn = (-0.1/cal[0][2])+cal[1][0]
21324  CalFile.write('<-0.1000' + '{0:.5f}'.format(CHAgn) + '>\n')
21325  CalFile.write('<>\n')
21326  CalFile.write('\n')
21327  # [2]
21328  CalFile.write('# Channel A, source V\n')
21329  CalFile.write('</>\n')
21330  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[2][0]) + '>\n')
21331  CHAgp = (5.0/cal[2][1])+cal[2][0]
21332  CalFile.write('<5.0000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
21333  CalFile.write('<>\n')
21334  CalFile.write('\n')
21335  # [3]
21336  CalFile.write('# Channel A, source I\n')
21337  CalFile.write('</>\n')
21338  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[3][0]) + '>\n')
21339  CHAgp = (0.1/cal[3][1])+cal[3][0]
21340  CalFile.write('<0.1000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
21341  CHAgn = (-0.1/cal[3][2])+cal[3][0]
21342  CalFile.write('<-0.1000, ' + '{0:.5f}'.format(CHAgn) + '>\n')
21343  CalFile.write('<>\n')
21344  CalFile.write('\n')
21345  # [4]
21346  CalFile.write('# Channel B, measure V\n')
21347  CalFile.write('</>\n')
21348  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[4][0]) + '>\n')
21349  CHAgp = (5.0/cal[4][1])+cal[4][0]
21350  CalFile.write('<5.0000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
21351  CalFile.write('<>\n')
21352  CalFile.write('\n')
21353  # [5]
21354  CalFile.write('# Channel B, measure I\n')
21355  CalFile.write('</>\n')
21356  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[5][0]) + '>\n')
21357  CHAgp = (0.1/cal[5][1])+cal[5][0]
21358  CalFile.write('<0.1000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
21359  CHAgn = (-0.1/cal[5][2])+cal[5][0]
21360  CalFile.write('<-0.1000, ' + '{0:.5f}'.format(CHAgn) + '>\n')
21361  CalFile.write('<>\n')
21362  CalFile.write('\n')
21363  # [6]
21364  CalFile.write('# Channel B, source V\n')
21365  CalFile.write('</>\n')
21366  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[6][0]) + '>\n')
21367  CHAgp = (5.0/cal[6][1])+cal[6][0]
21368  CalFile.write('<5.0000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
21369  CalFile.write('<>\n')
21370  CalFile.write('\n')
21371  # [7]
21372  CalFile.write('# Channel B source I\n')
21373  CalFile.write('</>\n')
21374  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[7][0]) + '>\n')
21375  CHAgp = (0.1/cal[7][1])+cal[7][0]
21376  CalFile.write('<0.1000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
21377  CHAgn = (-0.1/cal[7][2])+cal[7][0]
21378  CalFile.write('<-0.1000, ' + '{0:.5f}'.format(CHAgn) + '>\n')
21379  CalFile.write('<>\n')
21380  #
21381  CalFile.close()
21382 
21384 def SPIShiftOut(DValue):
21385  global devx, PIO_0, PIO_1, PIO_2, PIO_3, SCLKPort, SDATAPort, SLATCHPort
21386 
21387  binstr = bin(DValue)
21388  binlen = len(binstr)
21389  datastr = binstr[2:binlen]
21390  datalen = len(datastr)
21391  if datalen < 16:
21392  datastr = str.rjust(datastr , 16 , '0')
21393  datalen = len(datastr)
21394  i = 1
21395  devx.ctrl_transfer(0x40, 0x50, SLATCHPort.get(), 0, 0, 0, 100) # fsync to 0
21396  while i < datalen+1:
21397  # sending 0x50 = set to 0, 0x51 = set to 1
21398  D1code = 0x50 + int(datastr[i-1])
21399  devx.ctrl_transfer(0x40, D1code, SDATAPort.get(), 0, 0, 0, 100) # data bit
21400  devx.ctrl_transfer(0x40, 0x51, SCLKPort.get(), 0, 0, 0, 100) # sclk to 1
21401  devx.ctrl_transfer(0x40, 0x50, SCLKPort.get(), 0, 0, 0, 100) # sclk to 0
21402  devx.ctrl_transfer(0x40, 0x51, SCLKPort.get(), 0, 0, 0, 100) # sclk to 1
21403  i = i + 1
21404  devx.ctrl_transfer(0x40, 0x51, SLATCHPort.get(), 0, 0, 0, 100) # fsync to 1
21405 #
21406 def SetAD9833(temp):
21407  global FminEntry, HtMulEntry, MinigenFout, MinigenMode, etssrlab, EnableMinigenMode # , Fclk, Fout
21408  global Two28, mclk, EnableHSsampling, MinigenScreenStatus, ETSts, Two_X_Sample
21409 
21410  #
21411  if MinigenScreenStatus.get() == 0:
21412  #SRstring = "ET Sample Rate = " + str(SAMPLErate*MulX)
21413  #etssrlab.config(text=SRstring)
21414  return
21415  #
21416  if EnableMinigenMode == 2:
21417  MinigenMode.set(40)
21418  #
21419  try:
21420  FminE = float(eval(FminEntry.get()))*1000
21421  except:
21422  if EnableHSsampling > 0:
21423  FminEntry.delete(0,END)
21424  FminEntry.insert(0, FminE/1000)
21425  if MulX == 1:
21426  Fmin = FminE
21427  else:
21428  Fmin = FminE - (FminE/MulX)
21429  #
21430  MinigenFout.delete(0,"end")
21431  MinigenFout.insert(0,Fmin)
21432  #
21433  BSendMG()
21434 
21436 def BSendMG():
21437  global MinigenFclk, MinigenFout, MinigenMode
21438  global Two28, SCLKPort, SDATAPort, SLATCHPort
21439 
21440  DValue = 8192 + MinigenMode.get()
21441  SPIShiftOut(DValue)
21442  try:
21443  fout = float(eval(MinigenFout.get()))
21444  except:
21445  MinigenFout.delete(0,"end")
21446  MinigenFout.insert(0,100)
21447  try:
21448  mclk = float(eval(MinigenFclk.get()))*1000000 # convert from MHz to Hz
21449  except:
21450  MingenFclk.delete(0,"end")
21451  MinigenFclk.insert(0,16)
21452  Freg = int((fout*Two28)/mclk)
21453  Foutstr = bin(Freg)
21454  Foutlen = len(Foutstr)
21455  datastr = Foutstr[2:Foutlen]
21456  datalen = len(datastr)
21457  if datalen < 28:
21458  datastr = str.rjust(datastr , 28 , '0')
21459  datalen = len(datastr)
21460  Fmsb = '0b01' + datastr[0:14]
21461  Flsb = '0b01' + datastr[14:]
21462  FValue = int(eval(Flsb))
21463  SPIShiftOut(FValue)
21464  FValue = int(eval(Fmsb))
21465  SPIShiftOut(FValue)
21466 
21468 def MakeMinigenWindow():
21469  global RevDate, minigenwindow, MinigenMode, MinigenScreenStatus, MinigenFclk, MinigenFout, SWRev
21470  global SCLKPort, SDATAPort, SLATCHPort
21471  global GenericSerialStatus
21472  global PIO_0, PIO_1, PIO_2, PIO_3
21473 
21474  if GenericSerialStatus.get() == 1:
21475  GenericSerialStatus.set(0)
21477  if MinigenScreenStatus.get() == 0:
21478  MinigenScreenStatus.set(1)
21479  minigenwindow = Toplevel()
21480  minigenwindow.title("-AD983x DDS- " + SWRev + RevDate)
21481  minigenwindow.resizable(FALSE,FALSE)
21482  minigenwindow.protocol("WM_DELETE_WINDOW", DestroyMinigenScreen)
21483  #
21484  MinigenMode = IntVar(0)
21485  mgb1 = Radiobutton(minigenwindow, text="Sine", variable=MinigenMode, value=0, command=BSendMG )
21486  mgb1.grid(row=1, column=0, sticky=W)
21487  mgb2 = Radiobutton(minigenwindow, text="Triangle", variable=MinigenMode, value=2, command=BSendMG )
21488  mgb2.grid(row=1, column=1, columnspan=2, sticky=W)
21489  mgb3 = Radiobutton(minigenwindow, text="Square", variable=MinigenMode, value=40, command=BSendMG )
21490  mgb3.grid(row=2, column=0, sticky=W)
21491  mgb4 = Radiobutton(minigenwindow, text="Square/2", variable=MinigenMode, value=32, command=BSendMG )
21492  mgb4.grid(row=2, column=1, columnspan=2, sticky=W)
21493  f0lab = Label(minigenwindow, text="Mclk in MHz")
21494  f0lab.grid(row=3, column=0, columnspan=2, sticky=W)
21495  MinigenFclk = Entry(minigenwindow, width=5)
21496  MinigenFclk.grid(row=3, column=1, columnspan=2, sticky=W, padx=6)
21497  MinigenFclk.delete(0,"end")
21498  MinigenFclk.insert(0,16)
21499  f1lab = Label(minigenwindow, text="Output Freq")
21500  f1lab.grid(row=4, column=0, columnspan=2, sticky=W)
21501  MinigenFout = Entry(minigenwindow, width=8, cursor='double_arrow')
21502  MinigenFout.bind('<MouseWheel>', onMiniGenScroll)
21503  MinigenFout.bind("<Button-4>", onMiniGenScroll)# with Linux OS
21504  MinigenFout.bind("<Button-5>", onMiniGenScroll)
21505  MinigenFout.grid(row=4, column=1, columnspan=2, sticky=W)
21506  MinigenFout.delete(0,"end")
21507  MinigenFout.insert(0,100)
21508  bsn1 = Button(minigenwindow, text='UpDate', style="W7.TButton", command=BSendMG)
21509  bsn1.grid(row=5, column=0, sticky=W, pady=4)
21510  dismissmgbutton = Button(minigenwindow, text="Dismiss", style="W8.TButton", command=DestroyMinigenScreen)
21511  dismissmgbutton.grid(row=5, column=1, columnspan=2, sticky=W, pady=4)
21512  #
21513  label3 = Label(minigenwindow,text="SCLK PI/O Port ")
21514  label3.grid(row=6, column=0, sticky=W)
21515  sclk1 = Radiobutton(minigenwindow, text="0", variable=SCLKPort, value=PIO_0)
21516  sclk1.grid(row=6, column=1, sticky=W)
21517  sclk2 = Radiobutton(minigenwindow, text="1", variable=SCLKPort, value=PIO_1)
21518  sclk2.grid(row=6, column=2, sticky=W)
21519  sclk3 = Radiobutton(minigenwindow, text="2", variable=SCLKPort, value=PIO_2)
21520  sclk3.grid(row=6, column=3, sticky=W)
21521  sclk4 = Radiobutton(minigenwindow, text="3", variable=SCLKPort, value=PIO_3)
21522  sclk4.grid(row=6, column=4, sticky=W)
21523  #
21524  label4 = Label(minigenwindow,text="SData PI/O Port ")
21525  label4.grid(row=7, column=0, sticky=W)
21526  sdat1 = Radiobutton(minigenwindow, text="0", variable=SDATAPort, value=PIO_0)
21527  sdat1.grid(row=7, column=1, sticky=W)
21528  sdat2 = Radiobutton(minigenwindow, text="1", variable=SDATAPort, value=PIO_1)
21529  sdat2.grid(row=7, column=2, sticky=W)
21530  sdat3 = Radiobutton(minigenwindow, text="2", variable=SDATAPort, value=PIO_2)
21531  sdat3.grid(row=7, column=3, sticky=W)
21532  sdat4 = Radiobutton(minigenwindow, text="3", variable=SDATAPort, value=PIO_3)
21533  sdat4.grid(row=7, column=4, sticky=W)
21534  #
21535  label5 = Label(minigenwindow,text="FSync PI/O Port ")
21536  label5.grid(row=8, column=0, sticky=W)
21537  slth1 = Radiobutton(minigenwindow, text="0", variable=SLATCHPort, value=PIO_0)
21538  slth1.grid(row=8, column=1, sticky=W)
21539  slth2 = Radiobutton(minigenwindow, text="1", variable=SLATCHPort, value=PIO_1)
21540  slth2.grid(row=8, column=2, sticky=W)
21541  slth3 = Radiobutton(minigenwindow, text="2", variable=SLATCHPort, value=PIO_2)
21542  slth3.grid(row=8, column=3, sticky=W)
21543  slth4 = Radiobutton(minigenwindow, text="3", variable=SLATCHPort, value=PIO_3)
21544  slth4.grid(row=8, column=4, sticky=W)
21545  #
21546 
21548 def DestroyMinigenScreen():
21549  global minigenwindow, MinigenScreenStatus
21550 
21551  MinigenScreenStatus.set(0)
21552  minigenwindow.destroy()
21553 #
21554 def onMiniGenScroll(event):
21555  global ETSStatus, ETSDisp
21556 
21557  onTextScroll(event)
21558  BSendMG()
21559 
21561 def DA1ShiftOut(D1Value, D2Value):
21562  global devx
21563  global PIO_0, PIO_1, PIO_2, PIO_3
21564 
21565  binstr = bin(D1Value)
21566  binlen = len(binstr)
21567  data1str = binstr[2:binlen]
21568  datalen = len(data1str)
21569  if datalen < 16:
21570  data1str = str.rjust(data1str , 16 , '0')
21571  datalen = len(data1str)
21572  #
21573  binstr = bin(D2Value)
21574  binlen = len(binstr)
21575  data2str = binstr[2:binlen]
21576  datalen = len(data2str)
21577  if datalen < 16:
21578  data2str = str.rjust(data2str , 16 , '0')
21579  datalen = len(data2str)
21580  # sync --> PIO 0
21581  # D0 --> PIO 1
21582  # D1 --> PIO 2
21583  # SCLK --> PIO 3
21584  i = 1
21585 #
21586  devx.ctrl_transfer(0x40, 0x50, 0, 0, 0, 0, 100) # sync to 0
21587  while i < datalen+1:
21588  # sending 0x50 = set to 0, 0x51 = set to 1
21589  D1code = 0x50 + int(data1str[i-1])
21590  D2code = 0x50 + int(data2str[i-1])
21591  devx.ctrl_transfer(0x40, D1code, PIO_1, 0, 0, 0, 100) # data 0 bit
21592  devx.ctrl_transfer(0x40, D2code, PIO_2, 0, 0, 0, 100) # data 1 bit
21593  devx.ctrl_transfer(0x40, 0x51, PIO_3, 0, 0, 0, 100) # sclk to 1
21594  devx.ctrl_transfer(0x40, 0x50, PIO_3, 0, 0, 0, 100) # sclk to 0
21595  devx.ctrl_transfer(0x40, 0x51, PIO_3, 0, 0, 0, 100) # sclk to 1
21596  i = i + 1
21597  devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # sync to 1
21598  #
21599 def BSendDA1():
21600  global DAC1Entry, DAC2Entry, DAC3Entry, DAC4Entry, REFEntry
21601 
21602  try:
21603  RefValue = float(eval(REFEntry.get()))
21604  except:
21605  RefValue = 3.3
21606  try:
21607  D1Value = float(eval(DAC1Entry.get()))
21608  except:
21609  D1Value = 0.0129
21610  D1Code = int((D1Value/RefValue)*255)
21611  if D1Code > 255:
21612  D1Code = 255
21613  D1Code = D1Code + 0x2000
21614  try:
21615  D2Value = float(eval(DAC2Entry.get()))
21616  except:
21617  D2Value = 0.0129
21618  D2Code = int((D2Value/RefValue)*255)
21619  if D2Code > 255:
21620  D2Code = 255
21621  D2Code = D2Code + 0x2400
21622  try:
21623  D3Value = float(eval(DAC3Entry.get()))
21624  except:
21625  D3Value = 0.0129
21626  D3Code = int((D3Value/RefValue)*255)
21627  if D3Code > 255:
21628  D3Code = 255
21629  D3Code = D3Code + 0x2000
21630  try:
21631  D4Value = float(eval(DAC4Entry.get()))
21632  except:
21633  D4Value = 0.0129
21634  D4Code = int((D4Value/RefValue)*255)
21635  if D4Code > 255:
21636  D4Code = 255
21637  D4Code = D4Code + 0x2400
21638  #
21639  DA1ShiftOut(D1Code, D3Code)
21640  DA1ShiftOut(D2Code, D4Code)
21641 
21643 def MakeDA1Window():
21644  global da1window, DA1ScreenStatus, DAC1Entry, DAC2Entry, DAC3Entry, DAC4Entry
21645  global REFEntry, RevDate, SWRev
21646 
21647  if DA1ScreenStatus.get() == 0:
21648  DA1ScreenStatus.set(1)
21649  da1window = Toplevel()
21650  da1window.title("-DA1 PMOD- " + SWRev + RevDate)
21651  da1window.resizable(FALSE,FALSE)
21652  da1window.protocol("WM_DELETE_WINDOW", DestroyDA1Screen)
21653 #
21654  d1lab = Label(da1window, text="DAC A1 output")
21655  d1lab.grid(row=0, column=0, columnspan=1, sticky=W)
21656  DAC1Entry = Entry(da1window, width=5)
21657  DAC1Entry.grid(row=0, column=1, sticky=W)
21658  DAC1Entry.delete(0,"end")
21659  DAC1Entry.insert(0,0)
21660  d2lab = Label(da1window, text="DAC B1 output")
21661  d2lab.grid(row=1, column=0, columnspan=1, sticky=W)
21662  DAC2Entry = Entry(da1window, width=5)
21663  DAC2Entry.grid(row=1, column=1, sticky=W)
21664  DAC2Entry.delete(0,"end")
21665  DAC2Entry.insert(0,0)
21666 
21667  d3lab = Label(da1window, text="DAC A2 output")
21668  d3lab.grid(row=2, column=0, columnspan=1, sticky=W)
21669  DAC3Entry = Entry(da1window, width=5)
21670  DAC3Entry.grid(row=2, column=1, sticky=W)
21671  DAC3Entry.delete(0,"end")
21672  DAC3Entry.insert(0,0)
21673 
21674  d4lab = Label(da1window, text="DAC B2 output")
21675  d4lab.grid(row=3, column=0, columnspan=1, sticky=W)
21676  DAC4Entry = Entry(da1window, width=5)
21677  DAC4Entry.grid(row=3, column=1, sticky=W)
21678  DAC4Entry.delete(0,"end")
21679  DAC4Entry.insert(0,0)
21680 
21681  d5lab = Label(da1window, text="Reference V")
21682  d5lab.grid(row=4, column=0, columnspan=1, sticky=W)
21683  REFEntry = Entry(da1window, width=5)
21684  REFEntry.grid(row=4, column=1, sticky=W)
21685  REFEntry.delete(0,"end")
21686  REFEntry.insert(0,3.3)
21687 
21688  bsn1 = Button(da1window, text='UpDate', style="W7.TButton", command=BSendDA1)
21689  bsn1.grid(row=5, column=0, sticky=W)
21690  dismissdabutton = Button(da1window, text="Dismiss", style="W8.TButton", command=DestroyDA1Screen)
21691  dismissdabutton.grid(row=5, column=1, sticky=W, pady=4)
21692 
21694 def DestroyDA1Screen():
21695  global da1window, DA1ScreenStatus
21696 
21697  DA1ScreenStatus.set(0)
21698  da1window.destroy()
21699 
21700 def DigPotShiftOut(DValue):
21701  global devx, SingleDualPot
21702  global PIO_0, PIO_1, PIO_2, PIO_3
21703 
21704  binstr = bin(DValue)
21705  binlen = len(binstr)
21706  datastr = binstr[2:binlen]
21707  datalen = len(datastr)
21708  if SingleDualPot.get() == 0: # send 10 bits of data
21709  if datalen < 10:
21710  datastr = str.rjust(datastr , 10 , '0')
21711  datalen = len(datastr)
21712  if SingleDualPot.get() == 1: # send 8 bits of data
21713  if datalen < 8:
21714  datastr = str.rjust(datastr , 8 , '0')
21715  datalen = len(datastr)
21716  if SingleDualPot.get() == 2: # send 8 bits of data
21717  if datalen < 8:
21718  datastr = str.rjust(datastr , 8 , '0')
21719  datalen = len(datastr)
21720  i = 1
21721  devx.ctrl_transfer(0x40, 0x50, PIO_3, 0, 0, 0, 100) # clock to 0
21722  devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # CS to 0
21723  while i < datalen+1:
21724  # CS --> PIO 0
21725  # D0 --> PIO 1
21726  # D1 --> PIO 2
21727  # SCLK --> PIO 3
21728  D1code = 0x50 + int(datastr[i-1])
21729  devx.ctrl_transfer(0x40, D1code, PIO_1, 0, 0, 0, 100) # data bit
21730  devx.ctrl_transfer(0x40, 0x51, PIO_3, 0, 0, 0, 100) # clock to 1
21731  devx.ctrl_transfer(0x40, 0x50, PIO_3, 0, 0, 0, 100) # clock to 0
21732  i = i + 1
21733  devx.ctrl_transfer(0x40, 0x51, 0, 0, 0, 0, 100) # CS to 1
21734  #
21735 def DigPotSend(Temp):
21736  global DigPot1, DigPot2, DigPot3, DigPot4, SendPot1, SendPot2, SendPot3, SendPot4
21737  global SingleDualPot
21738 
21739  if SingleDualPot.get() == 0 or SingleDualPot.get() == 1:
21740  NumTaps = 255
21741  if SingleDualPot.get() == 2:
21742  NumTaps = 63
21743  try:
21744  DValue1 = DigPot1.get()
21745  if DValue1 > NumTaps:
21746  DValue1 = NumTaps
21747  except:
21748  DValue1 = 0
21749  try:
21750  DValue2 = DigPot2.get()
21751  if DValue2 > NumTaps:
21752  DValue2 = NumTaps
21753  except:
21754  DValue2 = 0
21755  try:
21756  DValue3 = DigPot3.get()
21757  if DValue3 > NumTaps:
21758  DValue3 = NumTaps
21759  except:
21760  DValue3 = 0
21761  try:
21762  DValue4 = DigPot4.get()
21763  if DValue4 > NumTaps:
21764  DValue4 = NumTaps
21765  except:
21766  DValue4 = 0
21767  if SendPot1.get() > 0:
21768  DigPotShiftOut(DValue1)
21769  if SendPot2.get() > 0:
21770  DigPotShiftOut(DValue2+NumTaps+1)
21771  if SendPot3.get() > 0:
21772  DigPotShiftOut(DValue3+2*(NumTaps+1))
21773  if SendPot4.get() > 0:
21774  DigPotShiftOut(DValue4+3*(NumTaps+1))
21775 
21776 def UpdatePotSlider():
21777  global SingleDualPot, DPotlabel, DigPot1, DigPot2, DigPot3, DigPot4
21778 
21779  if SingleDualPot.get() == 0 or SingleDualPot.get() == 1:
21780  DPotlabel.config(text="Enter number from 0 to 255")
21781  DigPot1.config(from_=0, to=255, length=256)
21782  DigPot2.config(from_=0, to=255, length=256)
21783  DigPot3.config(from_=0, to=255, length=256)
21784  DigPot4.config(from_=0, to=255, length=256)
21785  if SingleDualPot.get() == 2:
21786  DPotlabel.config(text="Enter number from 0 to 63")
21787  DigPot1.config(from_=0, to=63, length=64)
21788  DigPot2.config(from_=0, to=63, length=64)
21789  DigPot3.config(from_=0, to=63, length=64)
21790  DigPot4.config(from_=0, to=63, length=64)
21791 
21793 def MakeDigPotWindow():
21794  global digpotwindow, DigPotScreenStatus, DigPot1, DigPot2, DigPot3, DigPot4, RevDate
21795  global SendPot1, SendPot2, SendPot3, SendPot4, SingleDualPot, SWRev
21796  global DPotlabel, DigPot1, DigPot2, DigPot3, DigPot4
21797 
21798  if DigPotScreenStatus.get() == 0:
21799  DigPotScreenStatus.set(1)
21800  digpotwindow = Toplevel()
21801  digpotwindow.title("Digital Potentiometer " + SWRev + RevDate)
21802  digpotwindow.resizable(FALSE,FALSE)
21803  digpotwindow.protocol("WM_DELETE_WINDOW", DestroyDigPotScreen)
21804  #
21805  SendPot1 = IntVar(0)
21806  SendPot1.set(1)
21807  SendPot2 = IntVar(0)
21808  SendPot2.set(1)
21809  SendPot3 = IntVar(0)
21810  SendPot3.set(0)
21811  SendPot4 = IntVar(0)
21812  SendPot4.set(0)
21813  DPotlabel = Label(digpotwindow,text="Enter number from 0 to 255", style="A12B.TLabel")
21814  DPotlabel.grid(row=0, column=0, columnspan=3, sticky=W)
21815 
21816  SingleDualPot = IntVar(0)
21817  SingleDualPot.set(0)
21818  CompMenu = Menubutton(digpotwindow, text="Sel Comp.", style="W8.TButton")
21819  CompMenu.menu = Menu(CompMenu, tearoff = 0 )
21820  CompMenu["menu"] = CompMenu.menu
21821  CompMenu.menu.add_radiobutton(label="AD840X", variable=SingleDualPot, value=0, command=UpdatePotSlider)
21822  CompMenu.menu.add_radiobutton(label="AD5160", variable=SingleDualPot, value=1, command=UpdatePotSlider)
21823  CompMenu.menu.add_radiobutton(label="AD5203", variable=SingleDualPot, value=2, command=UpdatePotSlider)
21824  CompMenu.grid(row=1, column=0, columnspan=2, sticky=W)
21825  lab1 = Checkbutton(digpotwindow,text="Pot 1", variable=SendPot1)
21826  lab1.grid(row=2, column=0, sticky=W)
21827  DigPot1 = Scale(digpotwindow, from_=0, to=255, orient=HORIZONTAL, command=DigPotSend, length=256)
21828  DigPot1.grid(row=3, column=0, columnspan=3, sticky=W)
21829  lab2 = Checkbutton(digpotwindow,text="Pot 2", variable=SendPot2)
21830  lab2.grid(row=4, column=0, sticky=W)
21831  DigPot2 = Scale(digpotwindow, from_=0, to=255, orient=HORIZONTAL, command=DigPotSend, length=256)
21832  DigPot2.grid(row=5, column=0, columnspan=3, sticky=W)
21833  lab3 = Checkbutton(digpotwindow,text="Pot 3", variable=SendPot3)
21834  lab3.grid(row=6, column=0, sticky=W)
21835  DigPot3 = Scale(digpotwindow, from_=0, to=255, orient=HORIZONTAL, command=DigPotSend, length=256)
21836  DigPot3.grid(row=7, column=0, columnspan=3, sticky=W)
21837  lab4 = Checkbutton(digpotwindow,text="Pot 4", variable=SendPot4)
21838  lab4.grid(row=8, column=0, sticky=W)
21839  DigPot4 = Scale(digpotwindow, from_=0, to=255, orient=HORIZONTAL, command=DigPotSend, length=256)
21840  DigPot4.grid(row=9, column=0, columnspan=3, sticky=W)
21841  dismissdpbutton = Button(digpotwindow, text="Dismiss", style="W8.TButton", command=DestroyDigPotScreen)
21842  dismissdpbutton.grid(row=10, column=0, sticky=W, pady=4)
21843 
21844 def DestroyDigPotScreen():
21845  global digpotwindow, DigPotScreenStatus
21846 
21847  DigPotScreenStatus.set(0)
21848  digpotwindow.destroy()
21849 
21850 def BSendGS():
21851  global serialwindow, GenericSerialStatus, SCLKPort, SDATAPort, SLATCHPort, SLatchPhase, SClockPhase
21852  global NumBitsEntry, DataBitsEntry, devx, SerDirection, DValue, NumBits, AD5626SerialStatus, AD5626Entry
21853 
21854  if AD5626SerialStatus.get() == 0:
21855  try:
21856  DValue = int(eval(DataBitsEntry.get()))
21857  if DValue < 0:
21858  DValue = 0
21859  except:
21860  DValue = 0
21861  try:
21862  NumBits = int(NumBitsEntry.get())
21863  if NumBits < 1:
21864  NumBits = 1
21865  except:
21866  NumBits = 8
21867  else:
21868  try:
21869  DValue = int(eval(AD5626Entry.get())*1000)
21870  if DValue < 0:
21871  DValue = 0
21872  AD5626Entry.delete(0,"end")
21873  AD5626Entry.insert(0,'0.000')
21874  if DValue > 4095:
21875  DValue = 4095
21876  AD5626Entry.delete(0,"end")
21877  AD5626Entry.insert(0,DValue/1000.0)
21878  except:
21879  DValue = 0
21880  AD5626Entry.delete(0,"end")
21881  AD5626Entry.insert(0,'0.000')
21882  NumBits = 12
21883  # print DValue
21884  binstr = bin(DValue)
21885  binlen = len(binstr)
21886  datastr = binstr[2:binlen]
21887  datalen = len(datastr)
21888  if datalen < NumBits:
21889  datastr = str.rjust(datastr , NumBits , '0')
21890  datalen = len(datastr)
21891  if SLatchPhase.get() == 0:
21892  LatchInt = 0x50
21893  LatchEnd = 0x51
21894  else:
21895  LatchInt = 0x51
21896  LatchEnd = 0x50
21897  if AD5626SerialStatus.get() > 0:
21898  LatchInt = 0x51
21899  LatchEnd = 0x50
21900  if SClockPhase.get() == 0:
21901  ClockInt = 0x50
21902  ClockEnd = 0x51
21903  else:
21904  ClockInt = 0x51
21905  ClockEnd = 0x50
21906  devx.ctrl_transfer(0x40, ClockInt, SCLKPort.get(), 0, 0, 0, 100) # clock to start value
21907  devx.ctrl_transfer(0x40, LatchInt, SLATCHPort.get(), 0, 0, 0, 100) # CS to start value
21908  i = 1
21909  while i < datalen+1:
21910  if SerDirection.get() == 1: # for MSB first
21911  D1code = 0x50 + int(datastr[datalen-i]) # 0x50 = set to 0, 0x51 = set to 1
21912  else:
21913  D1code = 0x50 + int(datastr[i-1]) # for LSB first
21914  devx.ctrl_transfer(0x40, D1code, SDATAPort.get(), 0, 0, 0, 100) # data bit
21915  devx.ctrl_transfer(0x40, ClockEnd, SCLKPort.get(), 0, 0, 0, 100) # clock to end value
21916  devx.ctrl_transfer(0x40, ClockInt, SCLKPort.get(), 0, 0, 0, 100) # clock to start value
21917  i = i + 1
21918  devx.ctrl_transfer(0x40, ClockEnd, SCLKPort.get(), 0, 0, 0, 100) # clock to end value
21919  devx.ctrl_transfer(0x40, LatchEnd, SLATCHPort.get(), 0, 0, 0, 100) # CS to end value
21920  devx.ctrl_transfer(0x40, LatchInt, SLATCHPort.get(), 0, 0, 0, 100) # CS to start value
21921  devx.ctrl_transfer(0x40, LatchEnd, SLATCHPort.get(), 0, 0, 0, 100) # CS to end value
21922 
21924 def MakeAD5626Window():
21925  global ad5626window, AD5626SerialStatus, SCLKPort, SDATAPort, SLATCHPort, SLatchPhase, SClockPhase
21926  global GenericSerialStatus, AD5626Entry, SerDirection, SWRev
21927  global PIO_0, PIO_1, PIO_2, PIO_3
21928 
21929  if GenericSerialStatus.get() == 1:
21930  GenericSerialStatus.set(0)
21932  if AD5626SerialStatus.get() == 0:
21933  AD5626SerialStatus.set(1)
21934  ad5626window = Toplevel()
21935  ad5626window.title("AD5626 Output " + SWRev + RevDate)
21936  ad5626window.resizable(FALSE,FALSE)
21937  ad5626window.protocol("WM_DELETE_WINDOW", DestroyAD5626Screen)
21938 #
21939  SLatchPhase = IntVar(0)
21940  SLatchPhase.set(0)
21941  SClockPhase = IntVar(0)
21942  SClockPhase.set(1)
21943  SerDirection = IntVar(0)
21944  SerDirection.set(0)
21945  #
21946  label2 = Label(ad5626window,text="Enter Output Volts")
21947  label2.grid(row=1, column=0, columnspan=1, sticky=W)
21948  AD5626Entry = Entry(ad5626window, width=10, cursor='double_arrow')
21949  AD5626Entry.bind('<MouseWheel>', onAD5626Scroll)
21950  AD5626Entry.bind("<Button-4>", onAD5626Scroll)# with Linux OS
21951  AD5626Entry.bind("<Button-5>", onAD5626Scroll)
21952  AD5626Entry.grid(row=1, column=1, columnspan=3, sticky=W)
21953  AD5626Entry.delete(0,"end")
21954  AD5626Entry.insert(0,'0.000')
21955  #
21956  label3 = Label(ad5626window,text="SCLK PI/O Port ")
21957  label3.grid(row=2, column=0, columnspan=1, sticky=W)
21958  sclk1 = Radiobutton(ad5626window, text="0", variable=SCLKPort, value=PIO_0)
21959  sclk1.grid(row=2, column=1, sticky=W)
21960  sclk2 = Radiobutton(ad5626window, text="1", variable=SCLKPort, value=PIO_1)
21961  sclk2.grid(row=2, column=2, sticky=W)
21962  sclk3 = Radiobutton(ad5626window, text="2", variable=SCLKPort, value=PIO_2)
21963  sclk3.grid(row=2, column=3, sticky=W)
21964  sclk4 = Radiobutton(ad5626window, text="3", variable=SCLKPort, value=PIO_3)
21965  sclk4.grid(row=2, column=4, sticky=W)
21966  #
21967  label4 = Label(ad5626window,text="SData PI/O Port ")
21968  label4.grid(row=3, column=0, columnspan=1, sticky=W)
21969  sdat1 = Radiobutton(ad5626window, text="0", variable=SDATAPort, value=PIO_0)
21970  sdat1.grid(row=3, column=1, sticky=W)
21971  sdat2 = Radiobutton(ad5626window, text="1", variable=SDATAPort, value=PIO_1)
21972  sdat2.grid(row=3, column=2, sticky=W)
21973  sdat3 = Radiobutton(ad5626window, text="2", variable=SDATAPort, value=PIO_2)
21974  sdat3.grid(row=3, column=3, sticky=W)
21975  sdat4 = Radiobutton(ad5626window, text="3", variable=SDATAPort, value=PIO_3)
21976  sdat4.grid(row=3, column=4, sticky=W)
21977  #
21978  label5 = Label(ad5626window,text="Latch PI/O Port ")
21979  label5.grid(row=4, column=0, columnspan=1, sticky=W)
21980  slth1 = Radiobutton(ad5626window, text="0", variable=SLATCHPort, value=PIO_0)
21981  slth1.grid(row=4, column=1, sticky=W)
21982  slth2 = Radiobutton(ad5626window, text="1", variable=SLATCHPort, value=PIO_1)
21983  slth2.grid(row=4, column=2, sticky=W)
21984  slth3 = Radiobutton(ad5626window, text="2", variable=SLATCHPort, value=PIO_2)
21985  slth3.grid(row=4, column=3, sticky=W)
21986  slth4 = Radiobutton(ad5626window, text="3", variable=SLATCHPort, value=PIO_3)
21987  slth4.grid(row=4, column=4, sticky=W)
21988  #
21989  bsn1 = Button(ad5626window, text='Send', style="W5.TButton", command=BSendGS)
21990  bsn1.grid(row=5, column=0, sticky=W)
21991  dismissgsbutton = Button(ad5626window, text="Dismiss", style="W8.TButton", command=DestroyAD5626Screen)
21992  dismissgsbutton.grid(row=5, column=1, columnspan=2, sticky=W, pady=4)
21993 #
21994 def onAD5626Scroll(event):
21995  onTextScroll(event)
21996  BSendGS()
21997 
21998 def DestroyAD5626Screen():
21999  global ad5626window, AD5626SerialStatus
22000 
22001  AD5626SerialStatus.set(0)
22002  ad5626window.destroy()
22003 
22005  global serialwindow, GenericSerialStatus, SCLKPort, SDATAPort, SLATCHPort, SLatchPhase, SClockPhase
22006  global NumBitsEntry, DataBitsEntry, SerDirection, RevDate, SWRev
22007  global PIO_0, PIO_1, PIO_2, PIO_3
22008 
22009  if GenericSerialStatus.get() == 0:
22010  GenericSerialStatus.set(1)
22011  serialwindow = Toplevel()
22012  serialwindow.title("Generic Serial Output " + SWRev + RevDate)
22013  serialwindow.resizable(FALSE,FALSE)
22014  serialwindow.protocol("WM_DELETE_WINDOW", DestroyGenericSerialScreen)
22015  #
22016  SCLKPort = IntVar(0)
22017  SCLKPort.set(PIO_2)
22018  SDATAPort = IntVar(0)
22019  SDATAPort.set(PIO_1)
22020  SLATCHPort = IntVar(0)
22021  SLATCHPort.set(PIO_0)
22022  SLatchPhase = IntVar(0)
22023  SClockPhase = IntVar(0)
22024  SerDirection = IntVar(0)
22025  label = Label(serialwindow,text="Enter number of Bits")
22026  label.grid(row=1, column=0, columnspan=2, sticky=W)
22027  NumBitsEntry = Entry(serialwindow, width=3)
22028  NumBitsEntry.grid(row=1, column=2, sticky=W)
22029  NumBitsEntry.delete(0,"end")
22030  NumBitsEntry.insert(0,8)
22031  #
22032  label2 = Label(serialwindow,text="Enter Data Word")
22033  label2.grid(row=2, column=0, columnspan=1, sticky=W)
22034  DataBitsEntry = Entry(serialwindow, width=10)
22035  DataBitsEntry.grid(row=2, column=1, columnspan=3, sticky=W)
22036  DataBitsEntry.delete(0,"end")
22037  DataBitsEntry.insert(0,0)
22038  #
22039  label3 = Label(serialwindow,text="SCLK PI/O Port ")
22040  label3.grid(row=3, column=0, columnspan=1, sticky=W)
22041  sclk1 = Radiobutton(serialwindow, text="0", variable=SCLKPort, value=PIO_0)
22042  sclk1.grid(row=3, column=1, sticky=W)
22043  sclk2 = Radiobutton(serialwindow, text="1", variable=SCLKPort, value=PIO_1)
22044  sclk2.grid(row=3, column=2, sticky=W)
22045  sclk3 = Radiobutton(serialwindow, text="2", variable=SCLKPort, value=PIO_2)
22046  sclk3.grid(row=3, column=3, sticky=W)
22047  sclk4 = Radiobutton(serialwindow, text="3", variable=SCLKPort, value=PIO_3)
22048  sclk4.grid(row=3, column=4, sticky=W)
22049  #
22050  label4 = Label(serialwindow,text="SData PI/O Port ")
22051  label4.grid(row=4, column=0, columnspan=1, sticky=W)
22052  sdat1 = Radiobutton(serialwindow, text="0", variable=SDATAPort, value=PIO_0)
22053  sdat1.grid(row=4, column=1, sticky=W)
22054  sdat2 = Radiobutton(serialwindow, text="1", variable=SDATAPort, value=PIO_1)
22055  sdat2.grid(row=4, column=2, sticky=W)
22056  sdat3 = Radiobutton(serialwindow, text="2", variable=SDATAPort, value=PIO_2)
22057  sdat3.grid(row=4, column=3, sticky=W)
22058  sdat4 = Radiobutton(serialwindow, text="3", variable=SDATAPort, value=PIO_3)
22059  sdat4.grid(row=4, column=4, sticky=W)
22060  #
22061  label5 = Label(serialwindow,text="Latch PI/O Port ")
22062  label5.grid(row=5, column=0, columnspan=1, sticky=W)
22063  slth1 = Radiobutton(serialwindow, text="0", variable=SLATCHPort, value=PIO_0)
22064  slth1.grid(row=5, column=1, sticky=W)
22065  slth2 = Radiobutton(serialwindow, text="1", variable=SLATCHPort, value=PIO_1)
22066  slth2.grid(row=5, column=2, sticky=W)
22067  slth3 = Radiobutton(serialwindow, text="2", variable=SLATCHPort, value=PIO_2)
22068  slth3.grid(row=5, column=3, sticky=W)
22069  slth4 = Radiobutton(serialwindow, text="3", variable=SLATCHPort, value=PIO_3)
22070  slth4.grid(row=5, column=4, sticky=W)
22071  #
22072  label6 = Label(serialwindow,text="Latch Phase ")
22073  label6.grid(row=6, column=0, columnspan=1, sticky=W)
22074  sph1 = Radiobutton(serialwindow, text="0", variable=SLatchPhase, value=0)
22075  sph1.grid(row=6, column=1, sticky=W)
22076  sph2 = Radiobutton(serialwindow, text="1", variable=SLatchPhase, value=1)
22077  sph2.grid(row=6, column=2, sticky=W)
22078  #
22079  label7 = Label(serialwindow,text="Clock Phase ")
22080  label7.grid(row=7, column=0, columnspan=1, sticky=W)
22081  sph7 = Radiobutton(serialwindow, text="0", variable=SClockPhase, value=0)
22082  sph7.grid(row=7, column=1, sticky=W)
22083  sph8 = Radiobutton(serialwindow, text="1", variable=SClockPhase, value=1)
22084  sph8.grid(row=7, column=2, sticky=W)
22085  #
22086  sdir1 = Radiobutton(serialwindow, text="LSB First", variable=SerDirection, value=0 )
22087  sdir1.grid(row=8, column=0, sticky=W)
22088  sdir2 = Radiobutton(serialwindow, text="MSB First", variable=SerDirection, value=1 )
22089  sdir2.grid(row=8, column=1, columnspan=2, sticky=W)
22090 
22091  bsn1 = Button(serialwindow, text='Send', style="W5.TButton", command=BSendGS)
22092  bsn1.grid(row=9, column=0, sticky=W)
22093  dismissgsbutton = Button(serialwindow, text="Dismiss", style="W8.TButton", command=DestroyGenericSerialScreen)
22094  dismissgsbutton.grid(row=9, column=1, columnspan=2, sticky=W, pady=4)
22095 
22097  global serialwindow, GenericSerialStatus
22098 
22099  GenericSerialStatus.set(0)
22100  serialwindow.destroy()
22101 
22103 def MakeDigFiltWindow():
22104  global digfltwindow, DigFiltStatus, RevDate, SWRev, DeBugMode
22105  global DigFiltA, DigFiltB, DifFiltALength, DifFiltBLength, DifFiltAFile, DifFiltBFile
22106  global DigFiltABoxCar, DigFiltBBoxCar, BCALenEntry, BCBLenEntry
22107  global BCASkewEntry, BCBSkewEntry, DigDeSkewA, DigDeSkewB
22108  global AWGFiltA, AWGALenEntry, AWGFiltABoxCar, AWGFiltALength, AWGFiltAFile
22109  global AWGFiltB, AWGBLenEntry, AWGFiltBBoxCar, AWGFiltBLength, AWGFiltBFile
22110 
22111  if DigFiltStatus.get() == 0:
22112  DigFiltStatus.set(1)
22113  digfltwindow = Toplevel()
22114  digfltwindow.title("Digital Filter " + SWRev + RevDate)
22115  digfltwindow.resizable(FALSE,FALSE)
22116  digfltwindow.protocol("WM_DELETE_WINDOW", DestroyDigFiltScreen)
22117  #
22118  scriptbutton = Button(digfltwindow, text="Run Script", style="W11.TButton", command=RunScript)
22119  scriptbutton.grid(row=0, column=0, columnspan=1, sticky=W)
22120  dismissdfbutton = Button(digfltwindow, text="Dismiss", style="W8.TButton", command=DestroyDigFiltScreen)
22121  dismissdfbutton.grid(row=0, column=1, columnspan=1, sticky=W)
22122  frame2 = LabelFrame(digfltwindow, text="CH A Filter", style="A10R1.TLabelframe")
22123  frame3 = LabelFrame(digfltwindow, text="CH B Filter", style="A10R2.TLabelframe")
22124  #frame2.pack(side=LEFT, expand=1, fill=X)
22125  #frame3.pack(side=LEFT, expand=1, fill=X)
22126  frame2.grid(row=1, column=0, sticky=W)
22127  frame3.grid(row=1, column=1, sticky=W)
22128  frame4 = LabelFrame(digfltwindow, text="AWG A Filter", style="A10R1.TLabelframe")
22129  frame5 = LabelFrame(digfltwindow, text="AWG B Filter", style="A10R2.TLabelframe")
22130  frame4.grid(row=2, column=0, sticky=W)
22131  frame5.grid(row=2, column=1, sticky=W)
22132  #
22133  digfilta = Frame( frame2 )
22134  digfilta.pack(side=LEFT)
22135  #titlab = Label(digfltwindow,text="Apply Digital Filters ", style="A12B.TLabel")
22136  #titlab.grid(row=0, column=0, sticky=W)
22137  lab1 = Checkbutton(digfilta,text="Filter CH A", variable=DigFiltA)
22138  lab1.grid(row=0, column=0, columnspan=2, sticky=W)
22139  lab3 = Checkbutton(digfilta,text="Box Car", variable=DigFiltABoxCar, command=BuildBoxCarA)
22140  lab3.grid(row=1, column=0, sticky=W)
22141  BCALenEntry = Entry(digfilta, width=3, cursor='double_arrow')
22142  BCALenEntry.bind("<Return>", onRetDigFiltA)
22143  BCALenEntry.bind('<MouseWheel>', onDigFiltAScroll)
22144  BCALenEntry.bind("<Button-4>", onDigFiltAScroll)# with Linux OS
22145  BCALenEntry.bind("<Button-5>", onDigFiltAScroll)
22146  # BCALenEntry.bind('<Key>', onTextKey)
22147  BCALenEntry.grid(row=1, column=1, sticky=W)
22148  BCALenEntry.delete(0,"end")
22149  BCALenEntry.insert(0,2)
22150  bcalab = Label(digfilta, text="Length")
22151  bcalab.grid(row=1, column=2, sticky=W)
22152  DifFiltALength = Label(digfilta, text="Length = 0 ")
22153  DifFiltALength.grid(row=2, column=0, sticky=W)
22154  DifFiltAFile = Label(digfilta, text="File Name, none ")
22155  DifFiltAFile.grid(row=3, column=0, columnspan=3, sticky=W)
22156  cald = Button(digfilta, text='Load From File', command=BLoadDFiltA)
22157  cald.grid(row=4, column=0, columnspan=3, sticky=W)
22158  cacb = Button(digfilta, text='Load From Clip Board', command=BLoadDFiltAClip)
22159  cacb.grid(row=5, column=0, columnspan=3, sticky=W)
22160  camath = Button(digfilta, text='CH A Filter formula', command=BDFiltAMath)
22161  camath.grid(row=6, column=0, columnspan=3, sticky=W)
22162 
22163  # Deskew controls
22164  lab5 = Checkbutton(digfilta, text="DeSkew A", variable=DigDeSkewA)# , command=BuildBoxCarA)
22165  lab5.grid(row=7, column=0, sticky=W)
22166  BCASkewEntry = Entry(digfilta, width=3, cursor='double_arrow')
22167  BCASkewEntry.bind('<MouseWheel>', onTextScroll)
22168  BCASkewEntry.bind("<Button-4>", onTextScroll)# with Linux OS
22169  BCASkewEntry.bind("<Button-5>", onTextScroll)
22170  BCASkewEntry.grid(row=7, column=1, sticky=W)
22171  BCASkewEntry.delete(0,"end")
22172  BCASkewEntry.insert(0,0)
22173  bcasklab = Label(digfilta, text="# Samples")
22174  bcasklab.grid(row=7, column=2, sticky=W)
22175  #
22176  #dismissdfbutton = Button(digfilta, text="Dismiss", style="W8.TButton", command=DestroyDigFiltScreen)
22177  #dismissdfbutton.grid(row=7, column=0, columnspan=1, sticky=W)
22178  #
22179  digfiltb = Frame( frame3 )
22180  digfiltb.pack(side=RIGHT)
22181  lab2 = Checkbutton(digfiltb,text="Filter CH B", variable=DigFiltB)
22182  lab2.grid(row=0, column=0, columnspan=2, sticky=W)
22183  lab4 = Checkbutton(digfiltb,text="Box Car", variable=DigFiltBBoxCar, command=BuildBoxCarB)
22184  lab4.grid(row=1, column=0, sticky=W)
22185  BCBLenEntry = Entry(digfiltb, width=3, cursor='double_arrow')
22186  BCBLenEntry.bind("<Return>", onRetDigFiltB)
22187  BCBLenEntry.bind('<MouseWheel>', onDigFiltBScroll)
22188  BCBLenEntry.bind("<Button-4>", onDigFiltBScroll)# with Linux OS
22189  BCBLenEntry.bind("<Button-5>", onDigFiltBScroll)
22190  # BCALenEntry.bind('<Key>', onTextKey)
22191  BCBLenEntry.grid(row=1, column=1, sticky=W)
22192  BCBLenEntry.delete(0,"end")
22193  BCBLenEntry.insert(0,2)
22194  bcblab = Label(digfiltb, text="Length")
22195  bcblab.grid(row=1, column=2, sticky=W)
22196  DifFiltBLength = Label(digfiltb,text="Length = 0 ")
22197  DifFiltBLength.grid(row=2, column=0, sticky=W)
22198  DifFiltBFile = Label(digfiltb,text="File Name, none ")
22199  DifFiltBFile.grid(row=3, column=0, columnspan=3, sticky=W)
22200  cbld = Button(digfiltb, text='Load From File', command=BLoadDFiltB)
22201  cbld.grid(row=4, column=0, columnspan=3, sticky=W)
22202  cacb = Button(digfiltb, text='Load From Clip Board', command=BLoadDFiltBClip)
22203  cacb.grid(row=5, column=0, columnspan=3, sticky=W)
22204  cbmath = Button(digfiltb, text='CH B Filter formula', command=BDFiltBMath)
22205  cbmath.grid(row=6, column=0, columnspan=3, sticky=W)
22206  # Deskew controls
22207  lab6 = Checkbutton(digfiltb,text="DeSkew B", variable=DigDeSkewB)# , command=BuildBoxCarA)
22208  lab6.grid(row=7, column=0, sticky=W)
22209  BCBSkewEntry = Entry(digfiltb, width=3, cursor='double_arrow')
22210  BCBSkewEntry.bind('<MouseWheel>', onTextScroll)
22211  BCBSkewEntry.bind("<Button-4>", onTextScroll)# with Linux OS
22212  BCBSkewEntry.bind("<Button-5>", onTextScroll)
22213  BCBSkewEntry.grid(row=7, column=1, sticky=W)
22214  BCBSkewEntry.delete(0,"end")
22215  BCBSkewEntry.insert(0,0)
22216  bcbsklab = Label(digfiltb, text="# Samples")
22217  bcbsklab.grid(row=7, column=2, sticky=W)
22218  # AWG A controls
22219  awgfilta = Frame( frame4 )
22220  awgfilta.pack(side=LEFT)
22221  lab7 = Checkbutton(awgfilta,text="Filter AWG A", variable=AWGFiltA, command=ReMakeAWGwaves)
22222  lab7.grid(row=0, column=0, columnspan=2, sticky=W)
22223  lab8 = Checkbutton(awgfilta,text="Box Car", variable=AWGFiltABoxCar, command=BuildAWGBoxCarA)
22224  lab8.grid(row=1, column=0, sticky=W)
22225  AWGALenEntry = Entry(awgfilta, width=3, cursor='double_arrow')
22226  AWGALenEntry.bind("<Return>", onRetAWGFiltA)
22227  AWGALenEntry.bind('<MouseWheel>', onAWGFiltAScroll)
22228  AWGALenEntry.bind("<Button-4>", onAWGFiltAScroll)# with Linux OS
22229  AWGALenEntry.bind("<Button-5>", onAWGFiltAScroll)
22230  # BCALenEntry.bind('<Key>', onTextKey)
22231  AWGALenEntry.grid(row=1, column=1, sticky=W)
22232  AWGALenEntry.delete(0,"end")
22233  AWGALenEntry.insert(0,2)
22234  awgalab = Label(awgfilta, text="Length")
22235  awgalab.grid(row=1, column=2, sticky=W)
22236  AWGFiltALength = Label(awgfilta, text="Length = 0 ")
22237  AWGFiltALength.grid(row=2, column=0, sticky=W)
22238  AWGFiltAFile = Label(awgfilta, text="File Name, none ")
22239  AWGFiltAFile.grid(row=3, column=0, columnspan=3, sticky=W)
22240  awgaload = Button(awgfilta, text='Load From File', command=BLoadAWGFiltA)
22241  awgaload.grid(row=4, column=0, columnspan=3, sticky=W)
22242  awgacb = Button(awgfilta, text='Load From Clip Board', command=BLoadAWGAFiltClip)
22243  awgacb.grid(row=5, column=0, columnspan=3, sticky=W)
22244  awgamath = Button(awgfilta, text='AWG A Filter formula', command=BAWGFiltAMath)
22245  awgamath.grid(row=6, column=0, columnspan=3, sticky=W)
22246  #
22247  # AWG B controls
22248  awgfiltb = Frame( frame5 )
22249  awgfiltb.pack(side=RIGHT)
22250  lab9 = Checkbutton(awgfiltb,text="Filter AWG B", variable=AWGFiltB, command=ReMakeAWGwaves)
22251  lab9.grid(row=0, column=0, columnspan=2, sticky=W)
22252  lab10 = Checkbutton(awgfiltb,text="Box Car", variable=AWGFiltBBoxCar, command=BuildAWGBoxCarB)
22253  lab10.grid(row=1, column=0, sticky=W)
22254  AWGBLenEntry = Entry(awgfiltb, width=3, cursor='double_arrow')
22255  AWGBLenEntry.bind("<Return>", onRetAWGFiltB)
22256  AWGBLenEntry.bind('<MouseWheel>', onAWGFiltBScroll)
22257  AWGBLenEntry.bind("<Button-4>", onAWGFiltBScroll)# with Linux OS
22258  AWGBLenEntry.bind("<Button-5>", onAWGFiltBScroll)
22259  # BCALenEntry.bind('<Key>', onTextKey)
22260  AWGBLenEntry.grid(row=1, column=1, sticky=W)
22261  AWGBLenEntry.delete(0,"end")
22262  AWGBLenEntry.insert(0,2)
22263  awgblab = Label(awgfiltb, text="Length")
22264  awgblab.grid(row=1, column=2, sticky=W)
22265  AWGFiltBLength = Label(awgfiltb, text="Length = 0 ")
22266  AWGFiltBLength.grid(row=2, column=0, sticky=W)
22267  AWGFiltBFile = Label(awgfiltb, text="File Name, none ")
22268  AWGFiltBFile.grid(row=3, column=0, columnspan=3, sticky=W)
22269  awgbload = Button(awgfiltb, text='Load From File', command=BLoadAWGFiltB)
22270  awgbload.grid(row=4, column=0, columnspan=3, sticky=W)
22271  awgbcb = Button(awgfiltb, text='Load From Clip Board', command=BLoadAWGBFiltClip)
22272  awgbcb.grid(row=5, column=0, columnspan=3, sticky=W)
22273  awgbmath = Button(awgfiltb, text='AWG B Filter formula', command=BAWGFiltBMath)
22274  awgbmath.grid(row=6, column=0, columnspan=3, sticky=W)
22275  #
22276 def onRetDigFiltA(event):
22277  BuildBoxCarA()
22278 
22279 def onDigFiltAScroll(event):
22280  onTextScroll(event)
22281  BuildBoxCarA()
22282 
22283 def BuildBoxCarA():
22284  global BCALenEntry, DFiltACoef, DigFiltABoxCar, DifFiltALength
22285 
22286  if DigFiltABoxCar.get() == 0:
22287  return
22288 
22289  FLength = int(BCALenEntry.get())
22290  if FLength < 2:
22291  return
22292 
22293  DFiltACoef = [] # empty coef array
22294 
22295  for n in range(FLength):
22296  DFiltACoef.append(float(1.0/FLength))
22297 
22298  DFiltACoef = numpy.array(DFiltACoef)
22299  DifFiltALength.config(text = "Length = " + str(int(len(DFiltACoef)))) # change displayed length value
22300 
22301 def onRetDigFiltB(event):
22302  BuildBoxCarB()
22303 
22304 def onDigFiltBScroll(event):
22305  onTextScroll(event)
22306  BuildBoxCarB()
22307 
22308 def BuildBoxCarB():
22309  global BCBLenEntry, DFiltBCoef, DigFiltBBoxCar, DifFiltBLength
22310 
22311  if DigFiltBBoxCar.get() == 0:
22312  return
22313 
22314  FLength = int(BCBLenEntry.get())
22315  if FLength < 2:
22316  return
22317 
22318  DFiltBCoef = [] # empty coef array
22319 
22320  for n in range(FLength):
22321  DFiltBCoef.append(float(1.0/FLength))
22322 
22323  DFiltBCoef = numpy.array(DFiltBCoef)
22324  DifFiltBLength.config(text = "Length = " + str(int(len(DFiltBCoef)))) # change displayed length value
22325 
22326 def DestroyDigFiltScreen():
22327  global digfltwindow, DigFiltStatus
22328 
22329  DigFiltStatus.set(0)
22330  digfltwindow.destroy()
22331 
22332 def BLoadDFiltA():
22333  global DFiltACoef, digfltwindow, DifFiltALength, DifFiltAFile
22334 
22335 # Read values from CVS file
22336  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=digfltwindow)
22337  try:
22338  CSVFile = open(filename)
22339  csv_f = csv.reader(CSVFile)
22340  except:
22341  showwarning("WARNING","No such file found or wrong format!", parent=digfltwindow)
22342  return
22343  DFiltACoef = []
22344 
22345  for row in csv_f:
22346  try:
22347  DFiltACoef.append(float(row[0]))
22348  except:
22349  print( 'skipping non-numeric row')
22350  DFiltACoef = numpy.array(DFiltACoef)
22351  DifFiltALength.config(text = "Length = " + str(int(len(DFiltACoef)))) # change displayed length value
22352  DifFiltAFile.config(text = "File Name, " + os.path.basename(filename)) # change displayed file name
22353  CSVFile.close()
22354 #
22355 def BDFiltAMath():
22356  global DFiltACoef, digfltwindow, DifFiltALength, DifFiltAFile, DigFilterAString
22357 
22358  TempString = DigFilterAString
22359  DigFilterAString = askstring("CH A Filter Math Formula", "Current Formula: " + DigFilterAString + "\n\nNew Formula:\n", initialvalue=DigFilterAString, parent=digfltwindow)
22360  if (DigFilterAString == None): # If Cancel pressed, then None
22361  DigFilterAString = TempString
22362  return
22363  DFiltACoef = eval(DigFilterAString)
22364  DFiltACoef = numpy.array(DFiltACoef)
22365  coefsum = numpy.sum(DFiltACoef)
22366  DFiltACoef = DFiltACoef / coefsum # always normalize to a gain of one
22367  DifFiltALength.config(text = "Length = " + str(int(len(DFiltACoef)))) # change displayed length value
22368  DifFiltAFile.config(text = "Using Filter A formula" ) # change displayed file name
22369 
22370 def BLoadDFiltB():
22371  global DFiltBCoef, digfltwindow, DifFiltBLength, DifFiltBFile
22372 
22373 # Read values from CVS file
22374  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=digfltwindow)
22375  try:
22376  CSVFile = open(filename)
22377  csv_f = csv.reader(CSVFile)
22378  except:
22379  showwarning("WARNING","No such file found or wrong format!", parent=digfltwindow)
22380  return
22381  DFiltBCoef = []
22382 
22383  for row in csv_f:
22384  try:
22385  DFiltBCoef.append(float(row[0]))
22386  except:
22387  print( 'skipping non-numeric row')
22388  DFiltBCoef = numpy.array(DFiltBCoef)
22389  DifFiltBLength.config(text = "Length = " + str(int(len(DFiltBCoef)))) # change displayed length value
22390  DifFiltBFile.config(text = "File Name, " + os.path.basename(filename)) # change displayed file name
22391  CSVFile.close()
22392 #
22393 def BDFiltBMath():
22394  global DFiltBCoef, digfltwindow, DifFiltBLength, DifFiltBFile, DigFilterBString
22395 
22396  TempString = DigFilterBString
22397  DigFilterBString = askstring("CH B Filter Math Formula", "Current Formula: " + DigFilterBString + "\n\nNew Formula:\n", initialvalue=DigFilterBString, parent=digfltwindow)
22398  if (DigFilterBString == None): # If Cancel pressed, then None
22399  DigFilterBString = TempString
22400  return
22401  DFiltBCoef = eval(DigFilterBString)
22402  DFiltBCoef = numpy.array(DFiltBCoef)
22403  coefsum = numpy.sum(DFiltBCoef)
22404  DFiltBCoef = DFiltBCoef / coefsum
22405  DifFiltBLength.config(text = "Length = " + str(int(len(DFiltBCoef)))) # change displayed length value
22406  DifFiltBFile.config(text = "Using Filter B formula" ) # change displayed file name
22407 #
22408 def onRetAWGFiltA(event):
22409  BuildAWGBoxCarA()
22410 
22411 def onAWGFiltAScroll(event):
22412  onTextScroll(event)
22413  BuildAWGBoxCarA()
22414 
22415 def BuildAWGBoxCarA():
22416  global AWGALenEntry, AWGFiltACoef, AWGFiltABoxCar, AWGFiltALength
22417 
22418  if AWGFiltABoxCar.get() == 0:
22419  return
22420 
22421  FLength = int(AWGALenEntry.get())
22422  if FLength < 2:
22423  return
22424 
22425  AWGFiltACoef = [] # empty coef array
22426 
22427  for n in range(FLength):
22428  AWGFiltACoef.append(float(1.0/FLength))
22429 
22430  AWGFiltACoef = numpy.array(AWGFiltACoef)
22431  AWGFiltALength.config(text = "Length = " + str(int(len(AWGFiltACoef)))) # change displayed length value
22432  ReMakeAWGwaves()
22433 #
22434 def onRetAWGFiltB(event):
22435  BuildAWGBoxCarb()
22436 
22437 def onAWGFiltBScroll(event):
22438  onTextScroll(event)
22439  BuildAWGBoxCarB()
22440 
22441 def BuildAWGBoxCarB():
22442  global AWGBLenEntry, AWGFiltBCoef, AWGFiltBBoxCar, AWGFiltBLength
22443 
22444  if AWGFiltBBoxCar.get() == 0:
22445  return
22446 
22447  FLength = int(AWGBLenEntry.get())
22448  if FLength < 2:
22449  return
22450 
22451  AWGFiltBCoef = [] # empty coef array
22452 
22453  for n in range(FLength):
22454  AWGFiltBCoef.append(float(1.0/FLength))
22455 
22456  AWGFiltBCoef = numpy.array(AWGFiltBCoef)
22457  AWGFiltBLength.config(text = "Length = " + str(int(len(AWGFiltBCoef)))) # change displayed length value
22458  ReMakeAWGwaves()
22459 #
22460 def BLoadAWGFiltA():
22461  global AWGFiltACoef, digfltwindow, AWGFiltALength, AWGFiltAFile
22462 
22463 # Read values from CVS file
22464  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=digfltwindow)
22465  try:
22466  CSVFile = open(filename)
22467  csv_f = csv.reader(CSVFile)
22468  except:
22469  showwarning("WARNING","No such file found or wrong format!", parent=digfltwindow)
22470  return
22471  AWGFiltACoef = []
22472 
22473  for row in csv_f:
22474  try:
22475  AWGFiltACoef.append(float(row[0]))
22476  except:
22477  print( 'skipping non-numeric row')
22478  AWGFiltACoef = numpy.array(AWGFiltACoef)
22479  AWGFiltALength.config(text = "Length = " + str(int(len(AWGFiltACoef)))) # change displayed length value
22480  AWGFiltAFile.config(text = "File Name, " + os.path.basename(filename)) # change displayed file name
22481  CSVFile.close()
22482  ReMakeAWGwaves()
22483 #
22484 def BAWGFiltAMath():
22485  global AWGFiltACoef, digfltwindow, AWGFiltALength, AWGFiltAFile, AWGFilterAString
22486 
22487  TempString = AWGFilterAString
22488  AWGFilterAString = askstring("AWG A Filter Math Formula", "Current Formula: " + DigFilterAString + "\n\nNew Formula:\n", initialvalue=AWGFilterAString, parent=digfltwindow)
22489  if (AWGFilterAString == None): # If Cancel pressed, then None
22490  AWGFilterAString = TempString
22491  return
22492  AWGFiltACoef = eval(AWGFilterAString)
22493  AWGFiltACoef = numpy.array(AWGFiltACoef)
22494  coefsum = numpy.sum(AWGFiltACoef)
22495  AWGFiltACoef = AWGFiltACoef / coefsum
22496  AWGFiltALength.config(text = "Length = " + str(int(len(AWGFiltACoef)))) # change displayed length value
22497  AWGFiltAFile.config(text = "AWG A Filter formula" ) # change displayed file name
22498  ReMakeAWGwaves()
22499 #
22500 #
22501 def BLoadAWGFiltB():
22502  global AWGFiltBCoef, digfltwindow, AWGFiltbLength, AWGFiltBFile
22503 
22504 # Read values from CVS file
22505  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=digfltwindow)
22506  try:
22507  CSVFile = open(filename)
22508  csv_f = csv.reader(CSVFile)
22509  except:
22510  showwarning("WARNING","No such file found or wrong format!", parent=digfltwindow)
22511  return
22512  AWGFiltBCoef = []
22513 
22514  for row in csv_f:
22515  try:
22516  AWGFiltBCoef.append(float(row[0]))
22517  except:
22518  print( 'skipping non-numeric row')
22519  AWGFiltBCoef = numpy.array(AWGFiltBCoef)
22520  AWGFiltBLength.config(text = "Length = " + str(int(len(AWGFiltBCoef)))) # change displayed length value
22521  AWGFiltBFile.config(text = "File Name, " + os.path.basename(filename)) # change displayed file name
22522  CSVFile.close()
22523  ReMakeAWGwaves()
22524 #
22525 def BAWGFiltBMath():
22526  global AWGFiltBCoef, digfltwindow, AWGFiltBLength, AWGFiltBFile, AWGFilterBString
22527 
22528  TempString = AWGFilterBString
22529  AWGFilterBString = askstring("AWG B Filter Math Formula", "Current Formula: " + DigFilterBString + "\n\nNew Formula:\n", initialvalue=AWGFilterBString, parent=digfltwindow)
22530  if (AWGFilterBString == None): # If Cancel pressed, then None
22531  AWGFilterBString = TempString
22532  return
22533  AWGFiltBCoef = eval(AWGFilterBString)
22534  AWGFiltBCoef = numpy.array(AWGFiltBCoef)
22535  coefsum = numpy.sum(AWGFiltBCoef)
22536  AWGFiltBCoef = AWGFiltBCoef / coefsum
22537  AWGFiltBLength.config(text = "Length = " + str(int(len(AWGFiltBCoef)))) # change displayed length value
22538  AWGFiltBFile.config(text = "AWG B Filter formula" ) # change displayed file name
22539  ReMakeAWGwaves()
22540 #
22541 # Higher order SINC filters can be generated by convolving first order Box Car filters
22542 def BuildRejectFilter(Order, Freject, Fsample):
22543  # Order can be 1, 2, 3 or 4
22544  # Fsample = 100000
22545  # Calculate SINC1 oversample ratios for Freject
22546  osr = int(Fsample/Freject) #
22547  # osr60 = int(Fsample/60) # 60 Hz example
22548  # Create "boxcar" SINC1 filter
22549  sinc1 = numpy.ones(osr)
22550  # sinc1_60 = np.ones(osr60)
22551  # Calculate higher order filters
22552  sinc2 = numpy.convolve(sinc1, sinc1)
22553  sinc3 = numpy.convolve(sinc2, sinc1)
22554  sinc4 = numpy.convolve(sinc2, sinc2)
22555  fosr = float(Fsample/Freject)
22556  if Order == 1:
22557  return sinc1/fosr
22558  elif Order == 2:
22559  return sinc2/fosr
22560  elif Order == 3:
22561  return sinc3/fosr
22562  elif Order == 4:
22563  return sinc4/fosr
22564  else:
22565  return sinc1/fosr
22566  # Here's the SINC4-ish filter
22567  # with three zeros at 50Hz, one at 60Hz.
22568  # filt_50_60_rej = np.convolve(sinc3_50, sinc1_60)
22569 
22570 # Fit the function y = A * exp(B * x) to the data arrays xs and ys
22571 # returns (A, B)
22572 # From: https://mathworld.wolfram.com/LeastSquaresFittingExponential.html
22573 def fit_exp(xs, ys):
22574  S_x2_y = 0.0
22575  S_y_lny = 0.0
22576  S_x_y = 0.0
22577  S_x_y_lny = 0.0
22578  S_y = 0.0
22579  for (x,y) in zip(xs, ys):
22580  S_x2_y += x * x * y
22581  S_y_lny += y * numpy.log(y)
22582  S_x_y += x * y
22583  S_x_y_lny += x * y * numpy.log(y)
22584  S_y += y
22585  #end
22586  a = (S_x2_y * S_y_lny - S_x_y * S_x_y_lny) / (S_y * S_x2_y - S_x_y * S_x_y)
22587  b = (S_y * S_x_y_lny - S_x_y * S_y_lny) / (S_y * S_x2_y - S_x_y * S_x_y)
22588  return (numpy.exp(a), b)
22589 #
22590 def MakeCommandScreen():
22591  global commandwindow, CommandStatus, ExecString, LastCommand, RevDate, SWRev
22592 
22593  if CommandStatus.get() == 0:
22594  CommandStatus.set(1)
22595  commandwindow = Toplevel()
22596  commandwindow.title("Command Line " + SWRev + RevDate)
22597  commandwindow.resizable(FALSE,FALSE)
22598  commandwindow.protocol("WM_DELETE_WINDOW", DestroyCommandScreen)
22599  toplab = Label(commandwindow,text="Command Line Interface ", style="A12B.TLabel")
22600  toplab.grid(row=0, column=0, columnspan=4, sticky=W)
22601  cl1 = Label(commandwindow,text="Last command:")
22602  cl1.grid(row=1, column=0, sticky=W)
22603  LastCommand = Label(commandwindow,text=" ")
22604  LastCommand.grid(row=2, column=0, columnspan=4, sticky=W)
22605  ExecString = Entry(commandwindow, width=40)
22606  ExecString.bind("<Return>", RExecuteFromString)
22607  ExecString.grid(row=3, column=0, columnspan=4, sticky=W)
22608  ExecString.delete(0,"end")
22609  ExecString.insert(0,"")
22610  executeclbutton = Button(commandwindow, text="Execute", style="W8.TButton", command=BExecuteFromString)
22611  executeclbutton.grid(row=4, column=0, sticky=W, pady=8)
22612  scriptbutton = Button(commandwindow, text="Run Script", style="W10.TButton", command=RunScript)
22613  scriptbutton.grid(row=4, column=1, sticky=W, pady=8)
22614  #
22615  dismissclbutton = Button(commandwindow, text="Dismiss", style="W8.TButton", command=DestroyCommandScreen)
22616  dismissclbutton.grid(row=4, column=2, sticky=W, pady=7)
22617 
22618 def DestroyCommandScreen():
22619  global commandwindow, CommandStatus
22620 
22621  CommandStatus.set(0)
22622  commandwindow.destroy()
22623 
22624 def RExecuteFromString(temp):
22625 
22627 
22628 def BExecuteFromString(): # global VBuffA,AWGAwaveform;VBuffA=AWGAwaveform
22629  global ExecString, LastCommand
22630  global VBuffA, VBuffB, IBuffA, IBuffB, VFilterA, VFilterB
22631  global VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGAwaveform, AWGBwaveform
22632  global VUnAvgA, VUnAvgB, IUnAvgA, IUnAvgB, UnAvgSav
22633  global TgInput, TgEdge, SingleShot, AutoLevel, SingleShotSA, ManualTrigger
22634  global root, freqwindow, awgwindow, iawindow, xywindow, win1, win2
22635  global TRIGGERentry, TMsb, Xsignal, Ysignal, AutoCenterA, AutoCenterB
22636  global CHAsb, CHAIsb, CHBsb, CHBIsb, HScale, FreqTraceMode
22637  global CHAsbxy, CHAIsbxy, CHBsbxy, CHBIsbxy, HoldOffentry
22638  global CHAVPosEntryxy, CHBVPosEntryxy, CHAIPosEntryxy, CHBIPosEntryxy
22639  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, MathTrace, MathXUnits, MathYUnits
22640  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry, HozPossentry
22641  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGADutyCycleEntry
22642  global AWGAPhaseEntry, AWGAShape, AWGATerm, AWGAMode, AWGARepeatFlag, AWGBRepeatFlag
22643  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBDutyCycleEntry
22644  global AWGBPhaseEntry, AWGBShape, AWGBTerm, AWGBMode, AWGSync, AWGAIOMode, AWGBIOMode
22645  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
22646  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1, MeasDCI1, MeasMinI1
22647  global MeasMaxI1, MeasMidI1, MeasPPI1, MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2
22648  global MeasPPV2, MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2, MeasDiffAB, MeasDiffBA
22649  global MeasRMSV1, MeasRMSV2, MeasRMSI1, MeasRMSI2, MeasPhase, MeasDelay
22650  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ, IASource, DisplaySeries
22651  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
22652  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
22653  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, CutDC, AWG_Amp_Mode
22654  global FFTwindow, DBdivindex, DBlevel, TRACEmodeTime, TRACEaverage, Vdiv
22655  global SMPfftpwrTwo, SMPfft, StartFreqEntry, StopFreqEntry, ZEROstuffing
22656  global TimeDisp, XYDisp, FreqDisp, IADisp, AWGAPhaseDelay, AWGBPhaseDelay
22657  global RsystemEntry, ResScale, GainCorEntry, PhaseCorEntry
22658  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2
22659  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxScreenStatus, MuxEnb
22660  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry, muxwindow, ChopMuxMode, ChopTrig, DualMuxMode
22661  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
22662  global MathString, MathXString, MathYString, UserAString, UserALabel, UserBString, UserBLabel
22663  global MathAxis, MathXAxis, MathYAxis, Show_MathX, Show_MathY, MathScreenStatus, MathWindow
22664  global AWGAMathString, AWGBMathString, FFTUserWindowString, DigFilterAString, DigFilterBString
22665  global GRWF, GRHF, GRWBP, GRHBP, GRWXY, GRHXY, GRWIA, GRHIA, MeasureStatus
22666  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
22667  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
22668  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
22669  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
22670  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2, CHAI_RC_HP, CHBI_RC_HP
22671  global CHA_A1, CHA_A2, CHB_A1, CHB_A2, RelPhaseCenter, ImpedanceCenter
22672  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
22673  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
22674  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
22675  global AWGABurstFlag, AWGACycles, AWGABurstDelay, AWGAwaveform, AWGAcsvFile, AWGBcsvFile
22676  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay, AWGBwaveform, AWGAwavFile, AWGBwavFile
22677  global SCLKPort, SDATAPort, SLATCHPort, EnableHSsampling, FminEntry, HtMulEntry
22678  global phawindow, PhAca, PhAScreenStatus, PhADisp
22679  global GRWPhA, X0LPhA, GRHPhA, Y0TPhA, EnableScopeOnly
22680  global VScale, IScale, RefphEntry, SMPfft, BoardStatus, boardwindow, BrdSel
22681  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn, RollBt, Roll_Mode
22682  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D, ScreenWidth, ScreenHeight
22683  global TRACEwidth, ColorMode, ca, COLORcanvas, COLORtrace4, COLORtraceR4, COLORtext
22684  global AWGANoiseEntry, AWGBNoiseEntry, AWGAsbnoise, AWGBsbnoise
22685  global AWGFiltA, AWGALenEntry, AWGFiltABoxCar, AWGFiltALength, digfltwindow
22686  global AWGFiltB, AWGBLenEntry, AWGFiltBBoxCar, AWGFiltBLength
22687  global DFiltACoef, DFiltBCoef, AWGACoef, AWGBCoef
22688 
22689  try:
22690  exec( ExecString.get(), globals(), globals())
22691  # exec( ExecString.get() )
22692  LastCommand.config(text = ExecString.get() ) # change displayed last command
22693  except:
22694  LastCommand.config(text = "Syntax Error Encountered" ) # change displayed last command
22695  return()
22696 #
22697 def CAresize(event):
22698  global ca, GRW, XOL, GRH, Y0T, CANVASwidth, CANVASheight, FontSize
22699 
22700  XOL = FontSize * 7
22701  CANVASwidth = event.width - 4
22702  CANVASheight = event.height - 4
22703  GRW = CANVASwidth - (2 * X0L) # new grid width
22704  GRH = CANVASheight - (Y0T + (FontSize * 7)) # new grid height
22705  UpdateTimeAll()
22706 #
22707 def UpdateMeasureScreen():
22708  global ChaLab1, ChaLab12, ChaLab3, ChaLab4, ChaLab5, ChaLab6
22709  global ChaValue1, ChaValue2, ChaValue3, ChaValue4, ChaValue5, ChaValue6
22710  global ChbLab1, ChbLab12, ChbLab3, ChbLab4, ChbLab5, ChbLab6
22711  global ChbValue1, ChbValue2, ChbValue3, ChbValue4, ChbValue5, ChbValue6
22712  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
22713  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
22714 
22715  ValueText = ' {0:.4f} '.format(eval(ChaMeasString1))
22716  ChaValue1.config(text = ValueText)
22717  ValueText = ' {0:.4f} '.format(eval(ChaMeasString2))
22718  ChaValue2.config(text = ValueText)
22719  ValueText = ' {0:.4f} '.format(eval(ChaMeasString3))
22720  ChaValue3.config(text = ValueText)
22721  ValueText = ' {0:.4f} '.format(eval(ChaMeasString4))
22722  ChaValue4.config(text = ValueText)
22723  ValueText = ' {0:.4f} '.format(eval(ChaMeasString5))
22724  ChaValue5.config(text = ValueText)
22725  ValueText = ' {0:.4f} '.format(eval(ChaMeasString6))
22726  ChaValue6.config(text = ValueText)
22727  ValueText = ' {0:.4f} '.format(eval(ChbMeasString1))
22728  ChbValue1.config(text = ValueText)
22729  ValueText = ' {0:.4f} '.format(eval(ChbMeasString2))
22730  ChbValue2.config(text = ValueText)
22731  ValueText = ' {0:.4f} '.format(eval(ChbMeasString3))
22732  ChbValue3.config(text = ValueText)
22733  ValueText = ' {0:.4f} '.format(eval(ChbMeasString4))
22734  ChbValue4.config(text = ValueText)
22735  ValueText = ' {0:.4f} '.format(eval(ChbMeasString5))
22736  ChbValue5.config(text = ValueText)
22737  ValueText = ' {0:.4f} '.format(eval(ChbMeasString6))
22738  ChbValue6.config(text = ValueText)
22739 #
22740 def MakeMeasureScreen():
22741  global measurewindow, MeasureStatus, RevDate, SWRev
22742  global ChaLab1, ChaLab12, ChaLab3, ChaLab4, ChaLab5, ChaLab6
22743  global ChaValue1, ChaValue2, ChaValue3, ChaValue4, ChaValue5, ChaValue6
22744  global ChbLab1, ChbLab12, ChbLab3, ChbLab4, ChbLab5, ChbLab6
22745  global ChbValue1, ChbValue2, ChbValue3, ChbValue4, ChbValue5, ChbValue6
22746  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
22747  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
22748 
22749  if MeasureStatus.get() == 0:
22750  MeasureStatus.set(1)
22751  measurewindow = Toplevel()
22752  measurewindow.title("Measurements " + SWRev + RevDate)
22753  measurewindow.resizable(FALSE,FALSE)
22754  measurewindow.protocol("WM_DELETE_WINDOW", DestroyMeasureScreen)
22755  toplab = Label(measurewindow,text="Measurements ", style="A12B.TLabel")
22756  toplab.grid(row=0, column=0, columnspan=2, sticky=W)
22757  ChaLab1 = Label(measurewindow,text=ChaLableSrring1, style="A10B.TLabel")
22758  ChaLab1.grid(row=1, column=0, columnspan=1, sticky=W)
22759  ChaValue1 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
22760  ChaValue1.grid(row=1, column=1, columnspan=1, sticky=W)
22761  ChaLab2 = Label(measurewindow,text=ChaLableSrring2, style="A10B.TLabel")
22762  ChaLab2.grid(row=1, column=2, columnspan=1, sticky=W)
22763  ChaValue2 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
22764  ChaValue2.grid(row=1, column=3, columnspan=1, sticky=W)
22765  ChaLab3 = Label(measurewindow,text=ChaLableSrring3, style="A10B.TLabel")
22766  ChaLab3.grid(row=2, column=0, columnspan=1, sticky=W)
22767  ChaValue3 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
22768  ChaValue3.grid(row=2, column=1, columnspan=1, sticky=W)
22769  ChaLab4 = Label(measurewindow,text=ChaLableSrring4, style="A10B.TLabel")
22770  ChaLab4.grid(row=2, column=2, columnspan=1, sticky=W)
22771  ChaValue4 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
22772  ChaValue4.grid(row=2, column=3, columnspan=1, sticky=W)
22773  ChaLab5 = Label(measurewindow,text=ChaLableSrring5, style="A10B.TLabel")
22774  ChaLab5.grid(row=3, column=0, columnspan=1, sticky=W)
22775  ChaValue5 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
22776  ChaValue5.grid(row=3, column=1, columnspan=1, sticky=W)
22777  ChaLab6 = Label(measurewindow,text=ChaLableSrring6, style="A10B.TLabel")
22778  ChaLab6.grid(row=3, column=2, columnspan=1, sticky=W)
22779  ChaValue6 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
22780  ChaValue6.grid(row=3, column=3, columnspan=1, sticky=W)
22781  #
22782  ChbLab1 = Label(measurewindow,text=ChbLableSrring1, style="A10B.TLabel")
22783  ChbLab1.grid(row=4, column=0, columnspan=1, sticky=W)
22784  ChbValue1 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
22785  ChbValue1.grid(row=4, column=1, columnspan=1, sticky=W)
22786  ChbLab2 = Label(measurewindow,text=ChbLableSrring2, style="A10B.TLabel")
22787  ChbLab2.grid(row=4, column=2, columnspan=1, sticky=W)
22788  ChbValue2 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
22789  ChbValue2.grid(row=4, column=3, columnspan=1, sticky=W)
22790  ChbLab3 = Label(measurewindow,text=ChbLableSrring3, style="A10B.TLabel")
22791  ChbLab3.grid(row=5, column=0, columnspan=1, sticky=W)
22792  ChbValue3 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
22793  ChbValue3.grid(row=5, column=1, columnspan=1, sticky=W)
22794  ChbLab4 = Label(measurewindow,text=ChbLableSrring4, style="A10B.TLabel")
22795  ChbLab4.grid(row=5, column=2, columnspan=1, sticky=W)
22796  ChbValue4 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
22797  ChbValue4.grid(row=5, column=3, columnspan=1, sticky=W)
22798  ChbLab5 = Label(measurewindow,text=ChbLableSrring5, style="A10B.TLabel")
22799  ChbLab5.grid(row=6, column=0, columnspan=1, sticky=W)
22800  ChbValue5 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
22801  ChbValue5.grid(row=6, column=1, columnspan=1, sticky=W)
22802  ChbLab6 = Label(measurewindow,text=ChbLableSrring6, style="A10B.TLabel")
22803  ChbLab6.grid(row=6, column=2, columnspan=1, sticky=W)
22804  ChbValue6 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
22805  ChbValue6.grid(row=6, column=3, columnspan=1, sticky=W)
22806 #
22807 def DestroyMeasureScreen():
22808  global measurewindow, MeasureStatus
22809 
22810  MeasureStatus.set(0)
22811  measurewindow.destroy()
22812 #
22813 def MakeBoardScreen():
22814  global boardwindow, BoardStatus, session, devx, dev0, dev1, dev2, MultipleBoards
22815  global RevDate, BrdSel, FWRevOne, HWRevOne, FWRevTwo, HWRevTwo, WRevThree, HWRevThree
22816 
22817  if len(session.devices) > 1 and MultipleBoards.get() > 0: # make screen only if more than one board present
22818  if BoardStatus.get() == 0:
22819  BoardStatus.set(1)
22820  boardwindow = Toplevel()
22821  boardwindow.title("Select Board " + RevDate)
22822  boardwindow.resizable(FALSE,FALSE)
22823  boardwindow.protocol("WM_DELETE_WINDOW", DestroyBoardScreen)
22824  toplab = Label(boardwindow,text="- Select ALM1000 -", style="A12B.TLabel")
22825  toplab.pack(side=TOP)
22826  for idx, devx in enumerate(session.devices):
22827  BrdText = "Board # " + str(idx)
22828  if idx == 0:
22829  devx.set_led(0b010) # LED.green
22830  FWRevOne = float(devx.fwver)
22831  HWRevOne = devx.hwver
22832  dev0 = devx #session.devices[0]
22833  brd = Radiobutton(boardwindow, text=BrdText, style="Run.TRadiobutton", variable=BrdSel, value=idx, command=SelectBoard)
22834  elif idx == 1:
22835  devx.set_led(0b100) # LED.blue,
22836  FWRevTwo = float(devx.fwver)
22837  HWRevTwo = devx.hwver
22838  dev1 = devx #session.devices[1]
22839  brd = Radiobutton(boardwindow, text=BrdText, style="Stop.TRadiobutton", variable=BrdSel, value=idx, command=SelectBoard)
22840  elif idx == 2:
22841  devx.set_led(0b001) # LED.red,
22842  FWRevThree = float(devx.fwver)
22843  HWRevThree = devx.hwver
22844  dev2 = devx #session.devices[2]
22845  brd = Radiobutton(boardwindow, text=BrdText, variable=BrdSel, value=idx, command=SelectBoard)
22846  else:
22847  dev3 = session.devices[3]
22848  brd = Radiobutton(boardwindow, text=BrdText, variable=BrdSel, value=idx, command=SelectBoard)
22849  brd.pack(side=TOP)
22850  else:
22851  devx = session.devices[0]
22852  # devx.ignore_dataflow = True
22853  devx.set_led(0b010) # if only one board set LED.green
22854  try:
22855  FWRevOne = float(devx.fwver)
22856  HWRevOne = devx.hwver
22857  except:
22858  FWRevOne = "Before 2.06"
22859  HWRevOne = "?"
22860  dev0 = session.devices[0]
22861 #
22862 def DestroyBoardScreen():
22863  global boardwindow, BoardStatus
22864 
22865  BoardStatus.set(0)
22866  boardwindow.destroy()
22867 #
22868 def ConnectDevice():
22869  global devx, dev0, dev1, dev2, session, BrdSel, CHA, CHB, DevID, MaxSamples, AWGSAMPLErate
22870  global bcon, FWRevOne, HWRevOne, FWRevTwo, HWRevTwo, WRevThree, HWRevThree, SAMPLErate, MultipleBoards
22871 
22872  if DevID == "No Device" or DevID == "m1k":
22873  #print("Request sample rate: " + str(SAMPLErate))
22874  session = Session(ignore_dataflow=True, sample_rate=SAMPLErate, queue_size=MaxSamples)
22875  # session.add_all()
22876  # SAMPLErate = 200000 #AWGSAMPLErate # Scope sample rate
22877  if not session.devices:
22878  print( 'No Device plugged IN!')
22879  DevID = "No Device"
22880  FWRevOne = 0.0
22881  HWRevOne = "?"
22882  bcon.configure(text="Recon", style="RConn.TButton")
22883  return
22884  session.configure(sample_rate=SAMPLErate)
22885  # print("Session sample rate: " + str(session.sample_rate))
22886  MakeBoardScreen()
22887  SelectBoard()
22888  bcon.configure(text="Conn", style="GConn.TButton")
22889  devx.set_adc_mux(0)
22890  devx.ctrl_transfer(0x40, 0x24, 0x0, 0, 0, 0, 100) # set to addr DAC A
22891  devx.ctrl_transfer(0x40, 0x25, 0x1, 0, 0, 0, 100) # set not addr DAC B
22892 
22896  session.start(0)
22897 #
22898 def SelectBoard():
22899  global devx, dev0, dev1, dev2, session, BrdSel, CHA, CHB, DevID, RUNstatus, FWRevOne, HWRevOne
22900  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7, cal, SAMPLErate, MaxSamples
22901  global IgnoreFirmwareCheck, SDATAPort, SCLKPort, SLATCHPort
22902 
22903  if RUNstatus.get() == 1:
22904  BStop()
22905  print( "STOP")
22906 
22907  if BrdSel.get() == 0:
22908  try:
22909  session.remove(dev1)
22910  print( "Removing dev1")
22911  except:
22912  print( "Skipping dev1")
22913  try:
22914  session.remove(dev2)
22915  print( "Removing dev2")
22916  except:
22917  print( "Skipping dev2")
22918  session.add(dev0)
22919  devx = dev0
22920  #session.add(devx)
22921  if BrdSel.get() == 1:
22922  try:
22923  session.remove(dev0)
22924  print( "Removing dev0")
22925  except:
22926  print( "Skipping dev0")
22927  try:
22928  session.remove(dev2)
22929  print( "Removing dev2")
22930  except:
22931  print( "Skipping dev2")
22932  session.add(dev1)
22933  devx = dev1
22934  #session.add(devx)
22935  DevID = devx.serial
22936  print( DevID)
22937  FWRevOne = float(devx.fwver)
22938  HWRevOne = str(devx.hwver)
22939  print( FWRevOne, HWRevOne)
22940  # print("Session sample rate: " + str(session.sample_rate))
22941 
22942  if IgnoreFirmwareCheck == 0:
22943  if FWRevOne < 2.17:
22944  showwarning("WARNING","This ALICE version Requires Firmware version > 2.16")
22945  UpdateFirmware()
22946  cal = devx.calibration
22947  CHA = devx.channels['A'] # Open CHA
22948  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
22949  CHB = devx.channels['B'] # Open CHB
22950  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
22951  #
22952  # if session.continuous == 0:
22953  #session.start(0)
22954 
22963  devx.set_adc_mux(0)
22964  if devx.hwver == "F":
22965  print( "Rev F Board I/O ports set")
22966  PIO_0 = 28
22967  PIO_1 = 29
22968  PIO_2 = 47
22969  PIO_3 = 3
22970  PIO_4 = 4
22971  PIO_5 = 5
22972  PIO_6 = 6
22973  PIO_7 = 7
22974  else:
22975  PIO_0 = 0
22976  PIO_1 = 1
22977  PIO_2 = 2
22978  PIO_3 = 3
22979  PIO_4 = 4
22980  PIO_5 = 5
22981  PIO_6 = 6
22982  PIO_7 = 7
22983 #
22984  SDATAPort.set(PIO_1)
22985  SCLKPort.set(PIO_2)
22986  SLATCHPort.set(PIO_0)
22987 
22988 def MakeSampleRateMenu():
22989  global SAMPLErate, AWGSAMPLErate, BaseSampleRate, session, ETSStatus, etssrlab, RevDate
22990  global Two_X_Sample, ADC_Mux_Mode, SampleRatewindow, SampleRateStatus, BaseRatesb
22991  global Alternate_Sweep_Mode, DeBugMode, FWRevOne, SWRev, SampRateList
22992  global FrameRefief, BorderSize
22993 
22994  if SampleRateStatus.get() == 0:
22995  SampleRateStatus.set(1)
22996  SampleRatewindow = Toplevel()
22997  SampleRatewindow.title("Set Sample Rate " + SWRev + RevDate)
22998  SampleRatewindow.resizable(FALSE,FALSE)
22999  SampleRatewindow.protocol("WM_DELETE_WINDOW", DestroySampleRate)
23000  frame1 = Frame(SampleRatewindow, borderwidth=BorderSize, relief=FrameRefief)
23001  frame1.grid(row=0, column=0, sticky=W)
23002  #
23003  BaseRATE = Frame( frame1 )
23004  BaseRATE.grid(row=0, column=0, sticky=W)
23005  baseratelab = Label(BaseRATE, text="Base Sample Rate", style="A10B.TLabel") #, font = "Arial 10 bold")
23006  baseratelab.pack(side=LEFT)
23007  BaseRatesb = Spinbox(BaseRATE, width=6, values=SampRateList, command=SetSampleRate)
23008  BaseRatesb.bind('<MouseWheel>', onSrateScroll)
23009  BaseRatesb.bind("<Button-4>", onSrateScroll)# with Linux OS
23010  BaseRatesb.bind("<Button-5>", onSrateScroll)
23011  BaseRatesb.bind("<Return>", onRetSrate)
23012  BaseRatesb.pack(side=LEFT)
23013  BaseRatesb.delete(0,"end")
23014  BaseRatesb.insert(0,BaseSampleRate)
23015  #
23016  nextrow = 2
23017  if FWRevOne > 2.16:
23018  twoX = Checkbutton(frame1, text="Double Sample Rate", variable=Two_X_Sample, command=SetADC_Mux )
23019  twoX.grid(row=1, column=0, sticky=W)
23020  muxlab1 = Label(frame1, text="ADC MUX Modes", style="A10B.TLabel") #, font = "Arial 10 bold")
23021  muxlab1.grid(row=2, column=0, sticky=W)
23022  AltSweep = Checkbutton(frame1, text="Alternate Sweep Mode", variable=Alternate_Sweep_Mode ) #, command=SetADC_Mux )
23023  AltSweep.grid(row=3, column=0, sticky=W)
23024  chabuttons = Frame( frame1 )
23025  chabuttons.grid(row=4, column=0, sticky=W)
23026  muxrb1 = Radiobutton(chabuttons, text="VA and VB", variable=ADC_Mux_Mode, value=0, command=SetADC_Mux ) #style="W8.TButton",
23027  muxrb1.pack(side=LEFT)
23028  muxrb2 = Radiobutton(chabuttons, text="IA and IB", variable=ADC_Mux_Mode, value=1, command=SetADC_Mux ) #style="W8.TButton",
23029  muxrb2.pack(side=LEFT)
23030  chcbuttons = Frame( frame1 )
23031  chcbuttons.grid(row=5, column=0, sticky=W)
23032  muxrb5 = Radiobutton(chcbuttons, text="VA and IA", variable=ADC_Mux_Mode, value=4, command=SetADC_Mux ) # style="W8.TButton",
23033  muxrb5.pack(side=LEFT)
23034  muxrb6 = Radiobutton(chcbuttons, text="VB and IB", variable=ADC_Mux_Mode, value=5, command=SetADC_Mux ) # style="W8.TButton",
23035  muxrb6.pack(side=LEFT)
23036  nextrow = 6
23037  if DeBugMode == 1:
23038  chbbuttons = Frame( frame1 )
23039  chbbuttons.grid(row=nextrow, column=0, sticky=W)
23040  muxrb3 = Radiobutton(chbbuttons, text="VA and IB", variable=ADC_Mux_Mode, value=2, command=SetADC_Mux ) # style="W8.TButton",
23041  muxrb3.pack(side=LEFT)
23042  muxrb4 = Radiobutton(chbbuttons, text="VB and IA", variable=ADC_Mux_Mode, value=3, command=SetADC_Mux ) # style="W8.TButton",
23043  muxrb4.pack(side=LEFT)
23044  nextrow = nextrow + 1
23045  #
23046  sratedismissclbutton = Button(frame1, text="Dismiss", style="W8.TButton", command=DestroySampleRate)
23047  sratedismissclbutton.grid(row=nextrow, column=0, sticky=W, pady=7)
23048 #
23049 def DestroySampleRate():
23050  global SampleRatewindow, SampleRateStatus
23051 
23052  SampleRateStatus.set(0)
23053  SampleRatewindow.destroy()
23054 #
23055 #
23056 def onSrateScroll(event):
23057 
23058  #onTextScroll
23059  onSpinBoxScroll(event)
23060  SetSampleRate()
23061 #
23062 def onRetSrate(event):
23063 
23064  SetSampleRate()
23065 #
23066 def SetSampleRate():
23067  global SAMPLErate, BaseSampleRate, AWGSAMPLErate, session, ETSStatus, etssrlab, BaseRatesb
23068  global Two_X_Sample, ADC_Mux_Mode, rtsrlab, RUNstatus
23069 
23070  #
23071  WasRunning = 0
23072  if (RUNstatus.get() == 1):
23073  WasRunning = 1
23074  BStop() # Force Stop loop if running
23075  try:
23076  NewRate = int(BaseRatesb.get())
23077  if NewRate <= 100000: # rate has to be less than or equal to 100,000
23078  BaseSampleRate = NewRate
23079  else:
23080  BaseSampleRate = 100000
23081  BaseRatesb.delete(0,"end")
23082  BaseRatesb.insert(0,BaseSampleRate)
23083  SAMPLErate = BaseSampleRate # Scope sample rate
23084  except:
23085  donothing()
23086  session.configure(sample_rate=BaseSampleRate)
23087  BaseSampleRate = session.sample_rate
23088  #print("Session sample rate: " + str(session.sample_rate), BaseSampleRate)
23089  SAMPLErate = BaseSampleRate # Scope sample rate
23090  #print("Session sample rate: " + str(session.sample_rate), SAMPLErate)
23091  AWGSAMPLErate = BaseSampleRate
23092  if ETSStatus.get() > 0:
23093  SRstring = "RT Sample Rate = " + str(BaseSampleRate)
23094  rtsrlab.config(text=SRstring)
23095  ETSUpdate()
23096  BaseRatesb.delete(0,"end")
23097  BaseRatesb.insert(0,BaseSampleRate)
23098  ReMakeAWGwaves() # remake AWG waveforms for new rate
23099  if (WasRunning == 1):
23100  WasRunning = 0
23101  BStart() # restart loop if was running
23102 #
23103 def onStopfreqScroll(event):
23104  global StopFreqEntry, Two_X_Sample, ADC_Mux_Mode, FWRevOne
23105 
23106  onTextScroll(event)
23107  try:
23108  StopFrequency = float(StopFreqEntry.get())
23109  except:
23110  StopFreqEntry.delete(0,"end")
23111  StopFreqEntry.insert(0,50000)
23112  StopFrequency = 50000
23113  if FWRevOne > 2.16:
23114  if StopFrequency >= 50000:
23115  Two_X_Sample.set(1)
23116  ADC_Mux_Mode.set(0)
23117  SetADC_Mux()
23118  else:
23119  Two_X_Sample.set(0)
23120  ADC_Mux_Mode.set(0)
23121  SetADC_Mux()
23122 #
23123 def onStopBodeScroll(event):
23124  global StopBodeEntry, Two_X_Sample, ADC_Mux_Mode, FWRevOne
23125 
23126  onTextScroll(event)
23127  try:
23128  StopFrequency = float(StopBodeEntry.get())
23129  except:
23130  StopBodeEntry.delete(0,"end")
23131  StopBodeEntry.insert(0,20000)
23132  StopFrequency = 20000
23133  if FWRevOne > 2.16:
23134  if StopFrequency >= 20000:
23135  Two_X_Sample.set(1)
23136  ADC_Mux_Mode.set(0)
23137  SetADC_Mux()
23138  else:
23139  Two_X_Sample.set(0)
23140  ADC_Mux_Mode.set(0)
23141  SetADC_Mux()
23142 #
23143 def SetADC_Mux():
23144  global devx, SAMPLErate, BaseSampleRate, Two_X_Sample, ADC_Mux_Mode, CHA, CHB
23145  global v1_adc_conf, i1_adc_conf, v2_adc_conf, i2_adc_conf
23146  global AWGSync, discontloop, session, ADsignal1
23147 
23148  if Two_X_Sample.get() == 1:
23149  if ADC_Mux_Mode.get() == 0: # VA and VB
23150  devx.set_adc_mux(1)
23151  elif ADC_Mux_Mode.get() == 1: # IA and IB
23152  devx.set_adc_mux(2)
23153  elif ADC_Mux_Mode.get() == 2: # VA and IB
23154  # cycle trhough default mux values as starting point
23155  devx.set_adc_mux(2)
23156  # now set new mux values
23157  devx.set_adc_mux(7)
23158  devx.ctrl_transfer(0x40, 0x20, v1_adc_conf, 0, 0, 0, 100) # U12
23159  devx.ctrl_transfer(0x40, 0x21, i1_adc_conf, 0, 0, 0, 100) # U12
23160  devx.ctrl_transfer(0x40, 0x22, v2_adc_conf, 0, 0, 0, 100) # U11
23161  devx.ctrl_transfer(0x40, 0x22, i2_adc_conf, 0, 0, 0, 100) # U11
23162  time.sleep(0.1)
23163  elif ADC_Mux_Mode.get() == 3: # VB and IA
23164  # cycle trhough default mux values as starting point
23165  # now set new mux values
23166  devx.set_adc_mux(7)
23167  devx.ctrl_transfer(0x40, 0x20, v1_adc_conf, 0, 0, 0, 100) # U12
23168  devx.ctrl_transfer(0x40, 0x21, i1_adc_conf, 0, 0, 0, 100) # U12
23169  devx.ctrl_transfer(0x40, 0x22, v2_adc_conf, 0, 0, 0, 100) # U11
23170  devx.ctrl_transfer(0x40, 0x22, i2_adc_conf, 0, 0, 0, 100) # U11
23171  time.sleep(0.1)
23172  elif ADC_Mux_Mode.get() == 4: # VA and IA
23173  # cycle trhough default mux values as starting point
23174  devx.set_adc_mux(2)
23175  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
23176  if discontloop > 0:
23177  session.flush()
23178  else:
23179  discontloop = 1
23180  time.sleep(0.01)
23181  BAWGEnab()
23182  ADsignal1 = devx.get_samples(1000) # get samples for both channel A and B
23183 
23184  else: # running in continuous mode
23185  if session.continuous:
23186  ADsignal1 = devx.read(1000, -1, True) # get samples for both channel A and B
23187  # now set new mux values
23188  devx.set_adc_mux(4)
23189  elif ADC_Mux_Mode.get() == 5: # VB and IB
23190  # cycle trhough default mux values as starting point
23191  devx.set_adc_mux(2)
23192  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
23193  if discontloop > 0:
23194  session.flush()
23195  else:
23196  discontloop = 1
23197  time.sleep(0.01)
23198  BAWGEnab()
23199  ADsignal1 = devx.get_samples(1000) # get samples for both channel A and B
23200 
23201  else: # running in continuous mode
23202  if session.continuous:
23203  ADsignal1 = devx.read(1000, -1, True) # get samples for both channel A and B
23204  # now set new mux values
23205  devx.set_adc_mux(5)
23206  SAMPLErate = BaseSampleRate * 2 # set to 2X sample mode
23207  else:
23208  devx.set_adc_mux(0)
23209  SAMPLErate = BaseSampleRate
23210 #
23211 def TraceSelectADC_Mux():
23212  global ADC_Mux_Mode, Alternate_Sweep_Mode, ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
23213 
23214  if ShowC1_V.get() == 1 and ShowC1_I.get() == 1 and ShowC2_V.get() == 1 and ShowC2_I.get() == 1:
23215  ADC_Mux_Mode.set(0) # All four traces
23216  Alternate_Sweep_Mode.set(1)
23217  elif ShowC1_V.get() == 1 and ShowC1_I.get() == 1 and ShowC2_V.get() == 1 and ShowC2_I.get() == 0:
23218  ADC_Mux_Mode.set(0) # three traces
23219  Alternate_Sweep_Mode.set(1)
23220  elif ShowC1_V.get() == 1 and ShowC1_I.get() == 1 and ShowC2_V.get() == 0 and ShowC2_I.get() == 1:
23221  ADC_Mux_Mode.set(0) # three traces
23222  Alternate_Sweep_Mode.set(1)
23223  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 1 and ShowC2_V.get() == 1 and ShowC2_I.get() == 1:
23224  ADC_Mux_Mode.set(0) # three traces
23225  Alternate_Sweep_Mode.set(1)
23226  elif ShowC1_V.get() == 1 and ShowC1_I.get() == 0 and ShowC2_V.get() == 1 and ShowC2_I.get() == 1:
23227  ADC_Mux_Mode.set(0) # three traces
23228  Alternate_Sweep_Mode.set(1)
23229  #
23230  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 1 and ShowC2_V.get() == 0 and ShowC2_I.get() == 1:
23231  ADC_Mux_Mode.set(1) # IA and IB
23232  Alternate_Sweep_Mode.set(0)
23233  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 1 and ShowC2_V.get() == 0 and ShowC2_I.get() == 0:
23234  ADC_Mux_Mode.set(1) # just IA
23235  Alternate_Sweep_Mode.set(0)
23236  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 0 and ShowC2_V.get() == 0 and ShowC2_I.get() == 1:
23237  ADC_Mux_Mode.set(1) # just IB
23238  Alternate_Sweep_Mode.set(0)
23239  elif ShowC1_V.get() == 1 and ShowC1_I.get() == 1 and ShowC2_V.get() == 0 and ShowC2_I.get() == 0:
23240  ADC_Mux_Mode.set(4) # VA and IA
23241  Alternate_Sweep_Mode.set(0)
23242  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 0 and ShowC2_V.get() == 1 and ShowC2_I.get() == 1:
23243  ADC_Mux_Mode.set(5) # VB and IB
23244  Alternate_Sweep_Mode.set(0)
23245  else:
23246  ADC_Mux_Mode.set(0)
23247  Alternate_Sweep_Mode.set(0)
23248  SetADC_Mux()
23249  UpdateTimeTrace()
23250 #
23251 def UpdateFirmware():
23252  global devx, dev0, dev1, dev2, session, BrdSel, CHA, CHB, DevID, MaxSamples
23253  global bcon, FWRevOne, HWRevOne, FWRevTwo, HWRevTwo, WRevThree, HWRevThree
23254 
23255  RUNstatus.set(0)
23256  if askyesno("Update current firmware","Flash new firmware to current device:\n(Yes) or (No)?"):
23257  filename = askopenfilename(defaultextension = ".bin", filetypes=[("Binary", "*.bin")])
23258  print( filename)
23259  #print DevID
23260  #print FWRevOne, HWRevOne # devx.fwver, devx.hwver
23261  try:
23262  print( "Cancel current session.")
23263  session.cancel()
23264  print( session.cancelled)
23265  session.end()
23266  print( "Waiting 5...")
23267  time.sleep(5)
23268  print( "Put board in Samba mode and flash firmware.")
23269  session.flash_firmware(filename)
23270  except:
23271  showwarning("Complete","Flash Firmware Complete: \n Un-plug board to cycle power.")
23272 
23280  showwarning("Complete","Flash Firmware Complete: \n Un-plug board to cycle power.")
23281  showwarning("Exit ALICE","Must Exit Program: \n Restart ALICE to continue.")
23282  Bcloseexit()
23283 
23292 def MakeOhmWindow():
23293  global OhmDisp, OhmStatus, ohmwindow, RevDate, RMode, OhmA0, OhmA1, OhmRunStatus
23294  global CHATestVEntry, CHATestREntry, SWRev, AWGSync, OnBoardRes
23295  global FrameRefief, BorderSize
23296 
23297  if OhmStatus.get() == 0:
23298  AWGSync.set(1)
23299  OhmStatus.set(1)
23300  OhmDisp.set(1)
23301  OhmCheckBox()
23302  ohmwindow = Toplevel()
23303  ohmwindow.title("DC Ohmmeter " + SWRev + RevDate)
23304  ohmwindow.resizable(FALSE,FALSE)
23305  ohmwindow.protocol("WM_DELETE_WINDOW", DestroyOhmScreen)
23306  frame1 = Frame(ohmwindow, borderwidth=BorderSize, relief=FrameRefief)
23307  frame1.grid(row=0, column=0, sticky=W)
23308  #
23309  buttons = Frame( frame1 )
23310  buttons.grid(row=0, column=0, sticky=W)
23311  omrb2 = Radiobutton(buttons, text="Run", style="Run.TRadiobutton", variable=OhmRunStatus, value=1, command=BStartOhm )
23312  omrb2.pack(side=LEFT)
23313  omrb1 = Radiobutton(buttons, text="Stop", style="Stop.TRadiobutton", variable=OhmRunStatus, value=0, command=BStop )
23314  omrb1.pack(side=LEFT)
23315  #
23316  OhmA0 = Label(frame1, style="A16B.TLabel") # , font = "Arial 16 bold")
23317  OhmA0.grid(row=1, column=0, columnspan=2, sticky=W)
23318  OhmA0.config(text = "0.000 Ohms")
23319 
23320  OhmA1 = Label(frame1, style="A12B.TLabel") #, font = "Arial 12 bold")
23321  OhmA1.grid(row=2, column=0, columnspan=2, sticky=W)
23322  OhmA1.config(text = "Meas 0.00 mA 0.00 V")
23323  #
23324  TestVA = Frame( frame1 )
23325  TestVA.grid(row=3, column=0, sticky=W)
23326  chatestvlab = Label(TestVA, text="Test Voltage", style="A10B.TLabel") #, font = "Arial 10 bold")
23327  chatestvlab.pack(side=LEFT)
23328  CHATestVEntry = Entry(TestVA, width=6, cursor='double_arrow') #
23329  CHATestVEntry.pack(side=LEFT)
23330  CHATestVEntry.bind('<MouseWheel>', onTextScroll)
23331  CHATestVEntry.bind("<Button-4>", onTextScroll)# with Linux OS
23332  CHATestVEntry.bind("<Button-5>", onTextScroll)
23333  CHATestVEntry.delete(0,"end")
23334  CHATestVEntry.insert(0,5.0)
23335  #
23336  RMode = IntVar(0)
23337  RMode.set(1)
23338  TestMode = Frame( frame1 )
23339  TestMode.grid(row=4, column=0, sticky=W)
23340  modelab = Label(TestMode, text="Known Res", style="A10B.TLabel") #, font = "Arial 10 bold")
23341  modelab.pack(side=LEFT)
23342  rm3 = Radiobutton(TestMode, text="Ext", variable=RMode, value=0)
23343  rm3.pack(side=LEFT)
23344  rm4 = Radiobutton(TestMode, text="Int", variable=RMode, value=1)
23345  rm4.pack(side=LEFT)
23346  #
23347  TestRA = Frame( frame1 )
23348  TestRA.grid(row=5, column=0, sticky=W)
23349  chatestrlab = Label(TestRA, text="Known Res", style="A10B.TLabel") #, font = "Arial 10 bold")
23350  chatestrlab.pack(side=LEFT)
23351  CHATestREntry = Entry(TestRA, width=6, cursor='double_arrow') #
23352  CHATestREntry.pack(side=LEFT)
23353  CHATestREntry.bind('<MouseWheel>', onTextScroll)
23354  CHATestREntry.bind("<Button-4>", onTextScroll)# with Linux OS
23355  CHATestREntry.bind("<Button-5>", onTextScroll)
23356  CHATestREntry.delete(0,"end")
23357  CHATestREntry.insert(0,OnBoardRes)
23358  #
23359  ohmdismissclbutton = Button(frame1, text="Dismiss", style="W8.TButton", command=DestroyOhmScreen)
23360  ohmdismissclbutton.grid(row=6, column=0, sticky=W, pady=7)
23361 #
23362 def DestroyOhmScreen():
23363  global ohmwindow, OhmStatus, OhmDisp
23364 
23365  OhmStatus.set(0)
23366  OhmDisp.set(0)
23367  OhmCheckBox()
23368  ohmwindow.destroy()
23369 #
23370 def MakeETSWindow():
23371  global FMulXEntry, MulXEntry, etswindow, ETSStatus, ETSDisp, ETSDir, ETSts, eqivsamplerate
23372  global SAMPLErate, DivXEntry, FOffEntry, FminDisp, enb1, rtsrlab, etssrlab, RevDate, SWRev
23373  global MinigenScreenStatus, DeBugMode
23374  global FrameRefief, BorderSize
23375 
23376  #
23377  if ETSStatus.get() == 0:
23378  BaseFreq = (-10, -15, -20, -25, -30, -35, -40, -45, -50, -60, -70, -80, -90, -100)
23379  ETSStatus.set(1)
23380  ETSDisp.set(0)
23381  etswindow = Toplevel()
23382  etswindow.title("ETS Controls " + SWRev + RevDate)
23383  etswindow.resizable(FALSE,FALSE)
23384  etswindow.protocol("WM_DELETE_WINDOW", DestroyETSScreen)
23385  frame1 = Frame(etswindow, borderwidth=BorderSize, relief=FrameRefief)
23386  frame1.grid(row=0, column=0, sticky=W)
23387  # Sampling controls Widgets
23388  SRstring = "RT Sample Rate = " + str(SAMPLErate)
23389  rtsrlab = Label(frame1, text=SRstring, style= "A10B.TLabel")
23390  rtsrlab.grid(row=1, column=0, sticky=W)
23391  ESRstring = "ET Sample Rate = " + str(SAMPLErate)
23392  etssrlab = Label(frame1, text=SRstring, style= "A10B.TLabel")
23393  etssrlab.grid(row=2, column=0, sticky=W)
23394  etssrbutton = Button(frame1, text="Set RT Sample Rate", command=MakeSampleRateMenu) #, style= "W8.TButton"
23395  etssrbutton.grid(row=3, column=0, sticky=W, pady=7)
23396  enb1 = Checkbutton(frame1,text="Enable ETS", variable=ETSDisp, command=ETSCheckBox)
23397  enb1.grid(row=4, column=0, sticky=W)
23398  #
23399  Divx = Frame( frame1 )
23400  Divx.grid(row=5, column=0, sticky=W)
23401  DivXEntry = Entry(Divx, width=6, cursor='double_arrow')
23402  DivXEntry.bind('<MouseWheel>', ETSscroll)
23403  DivXEntry.bind("<Button-4>", ETSscroll)# with Linux OS
23404  DivXEntry.bind("<Button-5>", ETSscroll)
23405  DivXEntry.pack(side=RIGHT)
23406  DivXEntry.delete(0,"end")
23407  DivXEntry.insert(0,2)
23408  divxlab = Label( Divx, text = "Divide Factor")
23409  divxlab.pack(side=RIGHT)
23410  GridRow = 5
23411  #
23412  if DeBugMode > 0:
23413  FOffEntry = Label(frame1, text="Samples")
23414  FOffEntry.grid(row=GridRow+1, column=0, sticky=W)
23415  MulXEntry = Label( frame1, text = "Rec Len Mul")
23416  MulXEntry.grid(row=GridRow+2, column=0, sticky=W)
23417  GridRow = GridRow + 2
23418  #
23419  eqivsamplerate = Label(frame1, text="MHz", style= "A10B.TLabel")
23420  eqivsamplerate.grid(row=GridRow+1, column=0, sticky=W)
23421  #
23422  FConv = Frame( frame1 )
23423  FConv.grid(row=GridRow+2, column=0, sticky=W)
23424  FMulXEntry = Entry(FConv, width=3, cursor='double_arrow')
23425  FMulXEntry.bind('<MouseWheel>', ETSscroll)
23426  FMulXEntry.bind("<Button-4>", ETSscroll)# with Linux OS
23427  FMulXEntry.bind("<Button-5>", ETSscroll)
23428  FMulXEntry.pack(side=RIGHT)
23429  FMulXEntry.delete(0,"end")
23430  FMulXEntry.insert(0,1)
23431  fminlab = Label( FConv, text = "Freq Multiplier")
23432  fminlab.pack(side=RIGHT)
23433  #
23434  FminDisp = Label(frame1, text="32768 Hz", style= "A10B.TLabel")
23435  FminDisp.grid(row=GridRow+3, column=0, sticky=W)
23436  #
23437  if MinigenScreenStatus.get() > 0:
23438  mgloadbutton = Button(frame1, text="Load to MinGen", command=MGLoad)
23439  mgloadbutton.grid(row=GridRow+4, column=0, sticky=W)
23440  GridRow = GridRow + 1
23441  #
23442  dirlab = Label(frame1, text="Sample Data Order", style= "A10B.TLabel")
23443  dirlab.grid(row=GridRow+5, column=0, sticky=W)
23444  DataMode = Frame( frame1 )
23445  DataMode.grid(row=GridRow+6, column=0, sticky=W)
23446  dm3 = Radiobutton(DataMode, text="Forward", variable=ETSDir, value=0)
23447  dm3.pack(side=LEFT)
23448  dm4 = Radiobutton(DataMode, text="Reverse", variable=ETSDir, value=1)
23449  dm4.pack(side=LEFT)
23450  tclab = Label(frame1, text="CH B Time Shift", style= "A10B.TLabel")
23451  tclab.grid(row=GridRow+7, column=0, sticky=W)
23452  TSMode = Frame( frame1 )
23453  TSMode.grid(row=GridRow+8, column=0, sticky=W)
23454  ETSts = Entry(TSMode, width=6, cursor='double_arrow')
23455  ETSts.bind('<MouseWheel>', ETSscroll)
23456  ETSts.bind("<Button-4>", ETSscroll)# with Linux OS
23457  ETSts.bind("<Button-5>", ETSscroll)
23458  ETSts.pack(side=RIGHT)
23459  ETSts.delete(0,"end")
23460  ETSts.insert(0,1)
23461  ETStslab = Label( TSMode, text = "Factor")
23462  ETStslab.pack(side=RIGHT)
23463  #
23464  etsdismissclbutton = Button(frame1, text="Dismiss", style= "W8.TButton", command=DestroyETSScreen)
23465  etsdismissclbutton.grid(row=GridRow+9, column=0, sticky=W, pady=7)
23466  ETSDisp.set(0)
23467  ETSCheckBox()
23468 #
23469 def DestroyETSScreen():
23470  global etswindow, ETSStatus, ETSDisp
23471 
23472  ETSStatus.set(0)
23473  ETSDisp.set(0)
23474  ETSCheckBox()
23475  etswindow.destroy()
23476 #
23477 def MGLoad():
23478  global MinigenFout, Fmin, ETSDir
23479 
23480  MinigenFout.delete(0,"end")
23481  if ETSDir.get() == 0:
23482  MinigenFout.insert(0,Fmin+20)
23483  else:
23484  MinigenFout.insert(0,Fmin-20)
23485  BSendMG()
23486 #
23487 def ETSscroll(event):
23488  onTextScroll(event)
23489  ETSUpdate()
23490 #
23491 def onFminScroll(event):
23492  onTextScroll(event)
23493  ETSUpdate()
23494  SetETSComp()
23495  SetAD9833(event)
23496 
23497 def onMulXScroll(event):
23498  global Two_X_Sample, HtMulEntry, ETSts, etssrlab, SAMPLErate
23499 
23500  onTextScroll(event)
23501  # ETSUpdate()
23502  try:
23503  TscaleX = float(HtMulEntry.get())
23504  except:
23505  HtMulEntry.delete(0,END)
23506  HtMulEntry.insert(0, 1)
23507  if Two_X_Sample.get() == 0:
23508  ToffsetX = TscaleX/10.0 # set channel B offset to 1/10 the time scale only for 1X sampeling
23509  else:
23510  ToffsetX = 0
23511  ETSts.delete(0,"end")
23512  ETSts.insert(0,ToffsetX)
23513  SRstring = "ET Sample Rate = " + str(SAMPLErate*TscaleX)
23514  etssrlab.config(text=SRstring)
23515  #
23516  SetETSComp()
23517  SetAD9833(event)
23518 #
23519 def ETSUpdate():
23520  global FMulXEntry, MulXEntry, ETSStatus, ETSDisp, ETSDir, ETSts, eqivsamplerate, MaxETSrecord
23521  global SAMPLErate, DivXEntry, FOffEntry, FminDisp, DivX, FOff, MulX, Fmin, FMul, SAMPLErate, TIMEdiv
23522  global FminEntry, HtMulEntry, Two_X_Sample, DeBugMode
23523 
23524  if TIMEdiv > 0.2:
23525  MaxETSrecord = int(SAMPLErate * 10 * TIMEdiv / 1000.0)
23526  else:
23527  MaxETSrecord = int(SAMPLErate * 20 * TIMEdiv / 1000.0)
23528  if (MaxETSrecord*100) > MaxSamples:
23529  MaxETSrecord = MaxSamples / 100
23530  try:
23531  DivX = float(eval(DivXEntry.get()))
23532  if DivX < 2:
23533  DivX = 2
23534  if DivX > 75:
23535  DivX = 75
23536  DivXEntry.delete(0,END)
23537  DivXEntry.insert(0, DivX)
23538  except:
23539  DivXEntry.delete(0,END)
23540  DivXEntry.insert(0, DivX)
23541  #
23542  FOff = 25
23543  MulX = (DivX*SAMPLErate)/(100*FOff)
23544  while MulX > MaxETSrecord:
23545  FOff = FOff + 5
23546  MulX = (DivX*SAMPLErate)/(100*FOff)
23547  FOff = 0 - FOff
23548  if DeBugMode > 0:
23549  SRstring = "Rec Len Mul = " + str(MulX) + " samples"
23550  MulXEntry.config(text = SRstring) # change displayed value
23551  SRstring = "Offset = " + str(FOff) + " samples"
23552  FOffEntry.config(text = SRstring) # change displayed value
23553  baseFreq = SAMPLErate/DivX
23554  try:
23555  FMul = float(eval(FMulXEntry.get()))
23556  if FMul < 1:
23557  FMul = 1
23558  FMulXEntry.delete(0,END)
23559  FMulXEntry.insert(0, int(FMul))
23560  if FMul > 75:
23561  FMul = 75
23562  FMulXEntry.delete(0,END)
23563  FMulXEntry.insert(0, int(FMul))
23564  except:
23565  FMulXEntry.delete(0,END)
23566  FMulXEntry.insert(0, int(FMul))
23567  FreqMin = baseFreq * FMul
23568  SRstring = "Multiplied Freq = " + ' {0:.1f} '.format(FreqMin) + " Hz"
23569  FminDisp.config(text = SRstring) # change displayed value
23570  SRstring = "Base Frequency = " + ' {0:.2f} '.format(baseFreq) + " Hz"
23571  eqivsamplerate.config(text = SRstring) # change displayed value
23572  # calculate time scale multiplication factor
23573  try:
23574  MinFreq = eval(FminEntry.get()) * 1000 # convert KHz to Hz
23575  except:
23576  FminEntry.delete(0,END)
23577  FminEntry.insert(0, 25)
23578  #
23579  try: # catch for divide by zero
23580  TscaleX = int((MinFreq)/(DivX * (MinFreq - FreqMin)))
23581  except:
23582  TscaleX = 1
23583 
23584  if TscaleX > 0:
23585  ETSDir.set(0) # set sample direction to forward if positive
23586  else:
23587  ETSDir.set(1) # set sample direction to reverse if negative
23588  TscaleX = abs(TscaleX)
23589  if Two_X_Sample.get() == 0:
23590  ToffsetX = TscaleX/10.0 # set channel B offset to 1/10 the time scale only for 1X sampeling
23591  else:
23592  ToffsetX = 0
23593  ETSts.delete(0,"end")
23594  ETSts.insert(0,ToffsetX)
23595 
23596  HtMulEntry.delete(0,END)
23597  HtMulEntry.insert(0, TscaleX)
23598  SRstring = "RT Sample Rate = " + str(SAMPLErate)
23599  rtsrlab.config(text=SRstring)
23600  SRstring = "ET Sample Rate = " + str(SAMPLErate*TscaleX)
23601  etssrlab.config(text=SRstring)
23602 #
23603 def Settingsscroll(event):
23604  onTextScroll(event)
23605  SettingsUpdate()
23606 #
23607 def SettingsTextKey(event):
23608  onTextKey(event)
23609  SettingsUpdate()
23610 #
23611 def MakeSettingsMenu():
23612  global GridWidth, TRACEwidth, TRACEaverage, Vdiv, HarmonicMarkers, ZEROstuffing, RevDate
23613  global Settingswindow, SettingsStatus, ZSTuff, TAvg, VDivE, TwdthE, GwdthE, HarMon
23614  global AWG_Amp_Mode, SWRev, EnableHSsampling, Auto_ETS_Comp, ETS_TC1, ETS_A1, ETS_TC2, ETS_A2
23615  global ets_TC1Entry, ets_A1Entry, ets_TC2Entry, ets_A2Entry, TrgLPFEntry, Trigger_LPF_length
23616  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
23617  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
23618  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
23619  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
23620  global FrameRefief, BorderSize
23621 
23622  if SettingsStatus.get() == 0:
23623  SettingsStatus.set(1)
23624  Settingswindow = Toplevel()
23625  Settingswindow.title("Settings " + SWRev + RevDate)
23626  Settingswindow.resizable(FALSE,FALSE)
23627  Settingswindow.protocol("WM_DELETE_WINDOW", DestroySettings)
23628  frame1 = Frame(Settingswindow, borderwidth=BorderSize, relief=FrameRefief)
23629  frame1.grid(row=0, column=0, sticky=W)
23630  #
23631  zstlab = Label(frame1, text="FFT Zero Stuffing", style= "A10B.TLabel")
23632  zstlab.grid(row=0, column=0, sticky=W)
23633  zstMode = Frame( frame1 )
23634  zstMode.grid(row=0, column=1, sticky=W)
23635  ZSTuff = Entry(zstMode, width=4, cursor='double_arrow')
23636  ZSTuff.bind("<Return>", SettingsTextKey)
23637  ZSTuff.bind('<MouseWheel>', Settingsscroll)
23638  ZSTuff.bind("<Button-4>", Settingsscroll)# with Linux OS
23639  ZSTuff.bind("<Button-5>", Settingsscroll)
23640  ZSTuff.bind('<Key>', SettingsTextKey)
23641  ZSTuff.pack(side=RIGHT)
23642  ZSTuff.delete(0,"end")
23643  ZSTuff.insert(0,ZEROstuffing.get())
23644  #
23645  Avglab = Label(frame1, text="Number Traces to Average", style= "A10B.TLabel")
23646  Avglab.grid(row=1, column=0, sticky=W)
23647  AvgMode = Frame( frame1 )
23648  AvgMode.grid(row=1, column=1, sticky=W)
23649  TAvg = Entry(AvgMode, width=4, cursor='double_arrow')
23650  TAvg.bind("<Return>", SettingsTextKey)
23651  TAvg.bind('<MouseWheel>', Settingsscroll)
23652  TAvg.bind("<Button-4>", Settingsscroll)# with Linux OS
23653  TAvg.bind("<Button-5>", Settingsscroll)
23654  TAvg.bind('<Key>', SettingsTextKey)
23655  TAvg.pack(side=RIGHT)
23656  TAvg.delete(0,"end")
23657  TAvg.insert(0,TRACEaverage.get())
23658  #
23659  HarMlab = Label(frame1, text="Number of Harmonic Markers", style= "A10B.TLabel")
23660  HarMlab.grid(row=2, column=0, sticky=W)
23661  HarMMode = Frame( frame1 )
23662  HarMMode.grid(row=2, column=1, sticky=W)
23663  HarMon = Entry(HarMMode, width=4, cursor='double_arrow')
23664  HarMon.bind("<Return>", SettingsTextKey)
23665  HarMon.bind('<MouseWheel>', Settingsscroll)
23666  HarMon.bind("<Button-4>", Settingsscroll)# with Linux OS
23667  HarMon.bind("<Button-5>", Settingsscroll)
23668  HarMon.bind('<Key>', SettingsTextKey)
23669  HarMon.pack(side=RIGHT)
23670  HarMon.delete(0,"end")
23671  HarMon.insert(0,HarmonicMarkers.get())
23672  #
23673  Vdivlab = Label(frame1, text="Number Vertical Div (SA, Bode)", style= "A10B.TLabel")
23674  Vdivlab.grid(row=3, column=0, sticky=W)
23675  VdivMode = Frame( frame1 )
23676  VdivMode.grid(row=3, column=1, sticky=W)
23677  VDivE = Entry(VdivMode, width=4, cursor='double_arrow')
23678  VDivE.bind("<Return>", SettingsTextKey)
23679  VDivE.bind('<MouseWheel>', Settingsscroll)
23680  VDivE.bind("<Button-4>", Settingsscroll)# with Linux OS
23681  VDivE.bind("<Button-5>", Settingsscroll)
23682  VDivE.bind('<Key>', SettingsTextKey)
23683  VDivE.pack(side=RIGHT)
23684  VDivE.delete(0,"end")
23685  VDivE.insert(0,Vdiv.get())
23686  #
23687  Twdthlab = Label(frame1, text="Trace Width in Pixels", style= "A10B.TLabel")
23688  Twdthlab.grid(row=4, column=0, sticky=W)
23689  TwdthMode = Frame( frame1 )
23690  TwdthMode.grid(row=4, column=1, sticky=W)
23691  TwdthE = Entry(TwdthMode, width=4, cursor='double_arrow')
23692  TwdthE.bind("<Return>", SettingsTextKey)
23693  TwdthE.bind('<MouseWheel>', Settingsscroll)
23694  TwdthE.bind("<Button-4>", Settingsscroll)# with Linux OS
23695  TwdthE.bind("<Button-5>", Settingsscroll)
23696  TwdthE.bind('<Key>', SettingsTextKey)
23697  TwdthE.pack(side=RIGHT)
23698  TwdthE.delete(0,"end")
23699  TwdthE.insert(0,TRACEwidth.get())
23700  #
23701  Gwdthlab = Label(frame1, text="Grid Width in Pixels", style= "A10B.TLabel")
23702  Gwdthlab.grid(row=5, column=0, sticky=W)
23703  GwdthMode = Frame( frame1 )
23704  GwdthMode.grid(row=5, column=1, sticky=W)
23705  GwdthE = Entry(GwdthMode, width=4, cursor='double_arrow')
23706  GwdthE.bind("<Return>", SettingsTextKey)
23707  GwdthE.bind('<MouseWheel>', Settingsscroll)
23708  GwdthE.bind("<Button-4>", Settingsscroll)# with Linux OS
23709  GwdthE.bind("<Button-5>", Settingsscroll)
23710  GwdthE.bind('<Key>', SettingsTextKey)
23711  GwdthE.pack(side=RIGHT)
23712  GwdthE.delete(0,"end")
23713  GwdthE.insert(0,GridWidth.get())
23714  #
23715  trglpflab = Label(frame1, text="Trigger LPF Length", style= "A10B.TLabel")
23716  trglpflab.grid(row=6, column=0, sticky=W)
23717  TrgLPFMode = Frame( frame1 )
23718  TrgLPFMode.grid(row=6, column=1, sticky=W)
23719  TrgLPFEntry = Entry(TrgLPFMode, width=4, cursor='double_arrow')
23720  TrgLPFEntry.bind("<Return>", SettingsTextKey)
23721  TrgLPFEntry.bind('<MouseWheel>', Settingsscroll)
23722  TrgLPFEntry.bind("<Button-4>", Settingsscroll)# with Linux OS
23723  TrgLPFEntry.bind("<Button-5>", Settingsscroll)
23724  TrgLPFEntry.bind('<Key>', SettingsTextKey)
23725  TrgLPFEntry.pack(side=RIGHT)
23726  TrgLPFEntry.delete(0,"end")
23727  TrgLPFEntry.insert(0,Trigger_LPF_length.get())
23728  #
23729  AwgAmplrb1 = Radiobutton(frame1, text="AWG Min/Max", variable=AWG_Amp_Mode, value=0, command=UpdateAWGWin)
23730  AwgAmplrb1.grid(row=7, column=0, sticky=W)
23731  AwgAmplrb2 = Radiobutton(frame1, text="AWG Amp/Off ", variable=AWG_Amp_Mode, value=1, command=UpdateAWGWin)
23732  AwgAmplrb2.grid(row=7, column=1, sticky=W)
23733  #
23734  cha_Rcomplab = Label(frame1, text="CHA Comp, TC1 (uSec), A1", style= "A10B.TLabel") # in micro seconds
23735  cha_Rcomplab.grid(row=8, column=0, sticky=W)
23736  cha_RcomplabMode = Frame( frame1 )
23737  cha_RcomplabMode.grid(row=8, column=1, sticky=W)
23738  cha_TC1Entry = Entry(cha_RcomplabMode, width=5, cursor='double_arrow')
23739  cha_TC1Entry.bind("<Return>", SettingsTextKey)
23740  cha_TC1Entry.bind('<MouseWheel>', Settingsscroll)
23741  cha_TC1Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
23742  cha_TC1Entry.bind("<Button-5>", Settingsscroll)
23743  cha_TC1Entry.bind('<Key>', SettingsTextKey)
23744  cha_TC1Entry.pack(side=LEFT)
23745  cha_TC1Entry.delete(0,"end")
23746  cha_TC1Entry.insert(0,CHA_TC1.get())
23747  cha_A1Entry = Entry(cha_RcomplabMode, width=5, cursor='double_arrow')
23748  cha_A1Entry.bind("<Return>", SettingsTextKey)
23749  cha_A1Entry.bind('<MouseWheel>', Settingsscroll)
23750  cha_A1Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
23751  cha_A1Entry.bind("<Button-5>", Settingsscroll)
23752  cha_A1Entry.bind('<Key>', SettingsTextKey)
23753  cha_A1Entry.pack(side=LEFT)
23754  cha_A1Entry.delete(0,"end")
23755  cha_A1Entry.insert(0,CHA_A1.get())
23756  #
23757  cha_Ccomplab = Label(frame1, text="CHA Comp, TC2 (uSec), A2", style= "A10B.TLabel") # in micro seconds
23758  cha_Ccomplab.grid(row=9, column=0, sticky=W)
23759  cha_CcomplabMode = Frame( frame1 )
23760  cha_CcomplabMode.grid(row=9, column=1, sticky=W)
23761  cha_TC2Entry = Entry(cha_CcomplabMode, width=5, cursor='double_arrow')
23762  cha_TC2Entry.bind("<Return>", SettingsTextKey)
23763  cha_TC2Entry.bind('<MouseWheel>', Settingsscroll)
23764  cha_TC2Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
23765  cha_TC2Entry.bind("<Button-5>", Settingsscroll)
23766  cha_TC2Entry.bind('<Key>', SettingsTextKey)
23767  cha_TC2Entry.pack(side=LEFT)
23768  cha_TC2Entry.delete(0,"end")
23769  cha_TC2Entry.insert(0,CHA_TC2.get())
23770  cha_A2Entry = Entry(cha_CcomplabMode, width=5, cursor='double_arrow')
23771  cha_A2Entry.bind("<Return>", SettingsTextKey)
23772  cha_A2Entry.bind('<MouseWheel>', Settingsscroll)
23773  cha_A2Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
23774  cha_A2Entry.bind("<Button-5>", Settingsscroll)
23775  cha_A2Entry.bind('<Key>', SettingsTextKey)
23776  cha_A2Entry.pack(side=LEFT)
23777  cha_A2Entry.delete(0,"end")
23778  cha_A2Entry.insert(0,CHA_A2.get())
23779  #
23780  chb_Rcomplab = Label(frame1, text="CHB Comp, TC1 (uSec), A1", style= "A10B.TLabel") # in micro seconds
23781  chb_Rcomplab.grid(row=10, column=0, sticky=W)
23782  chb_RcomplabMode = Frame( frame1 )
23783  chb_RcomplabMode.grid(row=10, column=1, sticky=W)
23784  chb_TC1Entry = Entry(chb_RcomplabMode, width=5, cursor='double_arrow')
23785  chb_TC1Entry.bind("<Return>", SettingsTextKey)
23786  chb_TC1Entry.bind('<MouseWheel>', Settingsscroll)
23787  chb_TC1Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
23788  chb_TC1Entry.bind("<Button-5>", Settingsscroll)
23789  chb_TC1Entry.bind('<Key>', SettingsTextKey)
23790  chb_TC1Entry.pack(side=LEFT)
23791  chb_TC1Entry.delete(0,"end")
23792  chb_TC1Entry.insert(0,CHB_TC1.get())
23793  chb_A1Entry = Entry(chb_RcomplabMode, width=5, cursor='double_arrow')
23794  chb_A1Entry.bind("<Return>", SettingsTextKey)
23795  chb_A1Entry.bind('<MouseWheel>', Settingsscroll)
23796  chb_A1Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
23797  chb_A1Entry.bind("<Button-5>", Settingsscroll)
23798  chb_A1Entry.bind('<Key>', SettingsTextKey)
23799  chb_A1Entry.pack(side=LEFT)
23800  chb_A1Entry.delete(0,"end")
23801  chb_A1Entry.insert(0,CHB_A1.get())
23802  #
23803  chb_Ccomplab = Label(frame1, text="CHB Comp, TC2 (uSec), A2", style= "A10B.TLabel") # in micro seconds
23804  chb_Ccomplab.grid(row=11, column=0, sticky=W)
23805  chb_CcomplabMode = Frame( frame1 )
23806  chb_CcomplabMode.grid(row=11, column=1, sticky=W)
23807  chb_TC2Entry = Entry(chb_CcomplabMode, width=5, cursor='double_arrow')
23808  chb_TC2Entry.bind("<Return>", SettingsTextKey)
23809  chb_TC2Entry.bind('<MouseWheel>', Settingsscroll)
23810  chb_TC2Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
23811  chb_TC2Entry.bind("<Button-5>", Settingsscroll)
23812  chb_TC2Entry.bind('<Key>', SettingsTextKey)
23813  chb_TC2Entry.pack(side=LEFT)
23814  chb_TC2Entry.delete(0,"end")
23815  chb_TC2Entry.insert(0,CHB_TC2.get())
23816  chb_A2Entry = Entry(chb_CcomplabMode, width=5, cursor='double_arrow')
23817  chb_A2Entry.bind("<Return>", SettingsTextKey)
23818  chb_A2Entry.bind('<MouseWheel>', Settingsscroll)
23819  chb_A2Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
23820  chb_A2Entry.bind("<Button-5>", Settingsscroll)
23821  chb_A2Entry.bind('<Key>', SettingsTextKey)
23822  chb_A2Entry.pack(side=LEFT)
23823  chb_A2Entry.delete(0,"end")
23824  chb_A2Entry.insert(0,CHB_A2.get())
23825  #
23826  if EnableHSsampling > 0:
23827  hs_ckb1 = Checkbutton(frame1, text="Auto Set ETS Comp", variable=Auto_ETS_Comp, command=SetETSComp)
23828  hs_ckb1.grid(row=12, column=0, sticky=W)
23829  hs1_Complab = Label(frame1, text="ETS Comp, TC1 (uSec), A1", style= "A10B.TLabel") # in micro seconds
23830  hs1_Complab.grid(row=13, column=0, sticky=W)
23831  hs1_ComplabMode = Frame( frame1 )
23832  hs1_ComplabMode.grid(row=13, column=1, sticky=W)
23833  ets_TC1Entry = Entry(hs1_ComplabMode, width=5, cursor='double_arrow')
23834  ets_TC1Entry.bind("<Return>", SettingsTextKey)
23835  ets_TC1Entry.bind('<MouseWheel>', Settingsscroll)
23836  ets_TC1Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
23837  ets_TC1Entry.bind("<Button-5>", Settingsscroll)
23838  ets_TC1Entry.bind('<Key>', SettingsTextKey)
23839  ets_TC1Entry.pack(side=LEFT)
23840  ets_TC1Entry.delete(0,"end")
23841  ets_TC1Entry.insert(0,ETS_TC1.get())
23842  ets_A1Entry = Entry(hs1_ComplabMode, width=5, cursor='double_arrow')
23843  ets_A1Entry.bind("<Return>", SettingsTextKey)
23844  ets_A1Entry.bind('<MouseWheel>', Settingsscroll)
23845  ets_A1Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
23846  ets_A1Entry.bind("<Button-5>", Settingsscroll)
23847  ets_A1Entry.bind('<Key>', SettingsTextKey)
23848  ets_A1Entry.pack(side=LEFT)
23849  ets_A1Entry.delete(0,"end")
23850  ets_A1Entry.insert(0,ETS_A1.get())
23851  #
23852  hs2_Complab = Label(frame1, text="ETS Comp, TC2 (uSec), A2", style= "A10B.TLabel") # in micro seconds
23853  hs2_Complab.grid(row=14, column=0, sticky=W)
23854  hs2_ComplabMode = Frame( frame1 )
23855  hs2_ComplabMode.grid(row=14, column=1, sticky=W)
23856  ets_TC2Entry = Entry(hs2_ComplabMode, width=5, cursor='double_arrow')
23857  ets_TC2Entry.bind("<Return>", SettingsTextKey)
23858  ets_TC2Entry.bind('<MouseWheel>', Settingsscroll)
23859  ets_TC2Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
23860  ets_TC2Entry.bind("<Button-5>", Settingsscroll)
23861  ets_TC2Entry.bind('<Key>', SettingsTextKey)
23862  ets_TC2Entry.pack(side=LEFT)
23863  ets_TC2Entry.delete(0,"end")
23864  ets_TC2Entry.insert(0,ETS_TC2.get())
23865  ets_A2Entry = Entry(hs2_ComplabMode, width=5, cursor='double_arrow')
23866  ets_A2Entry.bind("<Return>", SettingsTextKey)
23867  ets_A2Entry.bind('<MouseWheel>', Settingsscroll)
23868  ets_A2Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
23869  ets_A2Entry.bind("<Button-5>", Settingsscroll)
23870  ets_A2Entry.bind('<Key>', SettingsTextKey)
23871  ets_A2Entry.pack(side=LEFT)
23872  ets_A2Entry.delete(0,"end")
23873  ets_A2Entry.insert(0,ETS_A2.get())
23874  #
23875  Settingsdismissbutton = Button(frame1, text="Dismiss", style= "W8.TButton", command=DestroySettings)
23876  Settingsdismissbutton.grid(row=15, column=0, sticky=W, pady=7)
23877  else:
23878  Settingsdismissbutton = Button(frame1, text="Dismiss", style= "W8.TButton", command=DestroySettings)
23879  Settingsdismissbutton.grid(row=12, column=0, sticky=W, pady=7)
23880 #
23881 def SetETSComp():
23882  global Auto_ETS_Comp, ETS_TC1, ETS_A1, ETS_TC2, ETS_A2
23883  global ets_TC1Entry, ets_A1Entry, ets_TC2Entry, ets_A2Entry
23884  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
23885  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
23886  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
23887  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
23888 
23889  if Auto_ETS_Comp.get() == 1:
23890  try:
23891  MulX = float(HtMulEntry.get())
23892  #
23893  Value = float(ets_TC1Entry.get()) * MulX
23894  cha_TC1Entry.delete(0,"end")
23895  cha_TC1Entry.insert(0, Value)
23896  cha_A1Entry.delete(0,"end")
23897  cha_A1Entry.insert(0, ets_A1Entry.get())
23898  chb_TC1Entry.delete(0,"end")
23899  chb_TC1Entry.insert(0, Value)
23900  chb_A1Entry.delete(0,"end")
23901  chb_A1Entry.insert(0, ets_A1Entry.get())
23902  #
23903  Value = float(ets_TC2Entry.get()) * MulX
23904  cha_TC2Entry.delete(0,"end")
23905  cha_TC2Entry.insert(0, Value)
23906  cha_A2Entry.delete(0,"end")
23907  cha_A2Entry.insert(0, ets_A2Entry.get())
23908  chb_TC2Entry.delete(0,"end")
23909  chb_TC2Entry.insert(0, Value)
23910  chb_A2Entry.delete(0,"end")
23911  chb_A2Entry.insert(0, ets_A2Entry.get())
23912  except:
23913  MulX = 1.0
23914 
23915 def UpdateAWGWin():
23916 
23917  UpdateAWGA()
23918  UpdateAWGB()
23919  ReMakeAWGwaves()
23920 
23921 def SettingsUpdate():
23922  global GridWidth, TRACEwidth, TRACEaverage, Vdiv, HarmonicMarkers, ZEROstuffing, RevDate
23923  global Settingswindow, SettingsStatus, ZSTuff, TAvg, VDivE, TwdthE, GwdthE, HarMon
23924  global CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
23925  global CHA_A1, CHA_A2, CHB_A1, CHB_A2, TrgLPFEntry, Trigger_LPF_length
23926  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
23927  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
23928 
23929  try:
23930  GW = int(eval(GwdthE.get()))
23931  if GW < 1:
23932  GW = 1
23933  GwdthE.delete(0,END)
23934  GwdthE.insert(0, int(GW))
23935  if GW > 5:
23936  GW = 5
23937  GwdthE.delete(0,END)
23938  GwdthE.insert(0, int(GW))
23939  except:
23940  GwdthE.delete(0,END)
23941  GwdthE.insert(0, GridWidth.get())
23942  GridWidth.set(GW)
23943  #
23944  try:
23945  T_length = int(eval(TrgLPFEntry.get()))
23946  if T_length < 1:
23947  T_length = 1
23948  TrgLPFEntry.delete(0,END)
23949  TrgLPFEntry.insert(0, int(GW))
23950  if T_length > 100:
23951  T_length = 100
23952  TrgLPFEntry.delete(0,END)
23953  TrgLPFEntry.insert(0, int(GW))
23954  except:
23955  TrgLPFEntry.delete(0,END)
23956  TrgLPFEntry.insert(0, Trigger_LPF_length.get())
23957  Trigger_LPF_length.set(T_length)
23958  #
23959  try:
23960  TW = int(eval(TwdthE.get()))
23961  if TW < 1:
23962  TW = 1
23963  TwdthE.delete(0,END)
23964  TwdthE.insert(0, int(TW))
23965  if TW > 5:
23966  TW = 5
23967  TwdthE.delete(0,END)
23968  TwdthE.insert(0, int(TW))
23969  except:
23970  TwdthE.delete(0,END)
23971  TwdthE.insert(0, TRACEwidth.get())
23972  TRACEwidth.set(TW)
23973  # Number of average sweeps for average mode
23974  try:
23975  TA = int(eval(TAvg.get()))
23976  if TA < 1:
23977  TA = 1
23978  TAvg.delete(0,END)
23979  TAvg.insert(0, int(TA))
23980  if TA > 16:
23981  TA = 16
23982  TAvg.delete(0,END)
23983  TAvg.insert(0, int(TA))
23984  except:
23985  TAvg.delete(0,END)
23986  TAvg.insert(0, TRACEaverage.get())
23987  TRACEaverage.set(TA)
23988  # Number of vertical divisions for spectrum / Bode
23989  try:
23990  VDv = int(eval(VDivE.get()))
23991  if VDv < 1:
23992  VDv = 1
23993  VDivE.delete(0,END)
23994  VDivE.insert(0, int(VDv))
23995  if VDv > 16:
23996  VDv = 16
23997  VDivE.delete(0,END)
23998  VDivE.insert(0, int(VDv))
23999  except:
24000  VDivE.delete(0,END)
24001  VDivE.insert(0, Vdiv.get())
24002  Vdiv.set(VDv)
24003  # number of Harmonic Markers in SA
24004  try:
24005  HM = int(eval(HarMon.get()))
24006  if HM < 1:
24007  HM = 1
24008  HarMon.delete(0,END)
24009  HarMon.insert(0, int(HM))
24010  if HM > 9:
24011  HM =9
24012  HarMon.delete(0,END)
24013  HarMon.insert(0, int(HM))
24014  except:
24015  HarMon.delete(0,END)
24016  HarMon.insert(0, HarmonicMarkers.get())
24017  HarmonicMarkers.set(HM)
24018  # The zero stuffing value is 2 ** ZERO stuffing, calculated on initialize
24019  try:
24020  ZST = int(eval(ZSTuff.get()))
24021  if ZST < 1:
24022  ZST = 1
24023  ZSTuff.delete(0,END)
24024  ZSTuff.insert(0, int(ZST))
24025  if ZST > 5:
24026  ZST = 5
24027  ZSTuff.delete(0,END)
24028  ZSTuff.insert(0, int(ZST))
24029  except:
24030  ZSTuff.delete(0,END)
24031  ZSTuff.insert(0, ZEROstuffing.get())
24032  ZEROstuffing.set(ZST)
24033 #
24034  try:
24035  TC1A = float(cha_TC1Entry.get())
24036  CHA_TC1.set(TC1A)
24037  if TC1A < 0:
24038  TC1A = 0
24039  cha_TC1Entry.delete(0,END)
24040  cha_TC1Entry.insert(0, TC1A)
24041  except:
24042  cha_TC1Entry.delete(0,END)
24043  cha_TC1Entry.insert(0, CHA_TC1.get())
24044  try:
24045  TC2A = float(cha_TC2Entry.get())
24046  CHA_TC2.set(TC2A)
24047  if TC2A < 0:
24048  TC2A = 0
24049  cha_TC2Entry.delete(0,END)
24050  cha_TC2Entry.insert(0, TC2A)
24051  except:
24052  cha_TC2Entry.delete(0,END)
24053  cha_TC2Entry.insert(0, CHA_TC2.get())
24054  #
24055  try:
24056  Gain1A = float(cha_A1Entry.get())
24057  CHA_A1.set(Gain1A)
24058  except:
24059  cha_A1Entry.delete(0,END)
24060  cha_A1Entry.insert(0, CHA_A1.get())
24061  try:
24062  Gain2A = float(cha_A2Entry.get())
24063  CHA_A2.set(Gain2A)
24064  except:
24065  cha_A2Entry.delete(0,END)
24066  cha_A2Entry.insert(0, CHA_A2.get())
24067  #
24068  try:
24069  TC1B = float(chb_TC1Entry.get())
24070  CHB_TC1.set(TC1B)
24071  if TC1B < 0:
24072  TC1B = 0
24073  chb_TC1Entry.delete(0, END)
24074  chb_TC1Entry.insert(0, TC1B)
24075  except:
24076  chb_TC1Entry.delete(0,END)
24077  chb_TC1Entry.insert(0, CHB_TC1.get())
24078  try:
24079  TC2B = float(chb_TC2Entry.get())
24080  CHB_TC2.set(TC2B)
24081  if TC2B < 0:
24082  TC2B = 0
24083  chb_TC2Entry.delete(0, END)
24084  chb_TC2Entry.insert(0, TC2B)
24085  except:
24086  chb_TC2Entry.delete(0,END)
24087  chb_TC2Entry.insert(0, CHB_TC2.get())
24088  #
24089  try:
24090  Gain1B = float(chb_A1Entry.get())
24091  CHB_A1.set(Gain1B)
24092  except:
24093  chb_A1Entry.delete(0,END)
24094  chb_A1Entry.insert(0, CHB_A1.get())
24095  try:
24096  Gain2B = float(chb_A2Entry.get())
24097  CHB_A2.set(Gain2B)
24098  except:
24099  chb_A2Entry.delete(0,END)
24100  chb_A2Entry.insert(0, CHB_A2.get())
24101  # set ETS base comp
24102  #
24103  SetETSComp()
24104 #
24105 def DestroySettings():
24106  global Settingswindow, SettingsStatus
24107 
24108  SettingsStatus.set(0)
24109  SettingsUpdate()
24110  Settingswindow.destroy()
24111 #
24112 def onCanvasMouse_xy(event):
24113  global MouseX, MouseY, MouseWidget
24114 
24115  MouseWidget = event.widget
24116  MouseX, MouseY = event.x, event.y
24117 #
24118 def BSetFmin():
24119  global FminEntry, CHAfreq
24120 
24121  if CHAfreq > 0:
24122  String = '{0:.3f}'.format(CHAfreq/1000)
24123  FminEntry.delete(0,"end")
24124  FminEntry.insert(0,String)
24125 #
24126 def ReSetAGO():
24127  global CHAVGainEntry, CHAVOffsetEntry
24128 
24129  CHAVGainEntry.delete(0,"end")
24130  CHAVGainEntry.insert(0,1.0)
24131  CHAVOffsetEntry.delete(0,"end")
24132  CHAVOffsetEntry.insert(0,0.0)
24133 #
24134 def ReSetBGO():
24135  global CHBVGainEntry, CHBVOffsetEntry
24136 
24137  CHBVGainEntry.delete(0,"end")
24138  CHBVGainEntry.insert(0,1.0)
24139  CHBVOffsetEntry.delete(0,"end")
24140  CHBVOffsetEntry.insert(0,0.0)
24141 #
24142 def ReSetAIGO():
24143  global CHAIGainEntry, CHAIOffsetEntry
24144 
24145  CHAIGainEntry.delete(0,"end")
24146  CHAIGainEntry.insert(0,1.0)
24147  CHAIOffsetEntry.delete(0,"end")
24148  CHAIOffsetEntry.insert(0,0.0)
24149 #
24150 def ReSetBIGO():
24151  global CHBIGainEntry, CHBIOffsetEntry
24152 
24153  CHBIGainEntry.delete(0,"end")
24154  CHBIGainEntry.insert(0,1.0)
24155  CHBIOffsetEntry.delete(0,"end")
24156  CHBIOffsetEntry.insert(0,0.0)
24157 #
24158 def OpenOtherTools():
24159  global EnablePhaseAnalizer, EnableSpectrumAnalizer, EnableBodePlotter, EnableImpedanceAnalizer
24160  global EnableOhmMeter, OOTphckb, OOTBuildPhAScreen, OOTckb3, OOTBuildSpectrumScreen, OOTckb5, ckb1
24161  global OOTBuildBodeScreen, OOTckb4, OOTBuildIAScreen, OOTckb6, OOTBuildOhmScreen, OOTScreenStatus
24162  global OOTwindow, SWRev, RevDate, BorderSize, FrameRefief, OOTdismissclbutton, EnableDigIO
24163  global EnablePIODACMode, EnableMuxMode, EnableMinigenMode, EnablePmodDA1Mode, EnableDigPotMode, EnableGenericSerialMode
24164  global EnableAD5626SerialMode, EnableDigitalFilter, EnableCommandInterface, EnableMeasureScreen, EnableETSScreen
24165 
24166  if OOTScreenStatus.get() == 0:
24167  OOTScreenStatus.set(1)
24168  OOTwindow = Toplevel()
24169  OOTwindow.title("Instruments " + SWRev + RevDate)
24170  OOTwindow.resizable(FALSE,FALSE)
24171  OOTwindow.protocol("WM_DELETE_WINDOW", DestroyOOTwindow)
24172  frame1 = Frame(OOTwindow, borderwidth=BorderSize, relief=FrameRefief)
24173  frame1.grid(row=0, column=0, sticky=W)
24174  #
24175  nextrow = 1
24176  timebtn = Frame( frame1 )
24177  timebtn.grid(row=nextrow, column=0, sticky=W)
24178  ckb1 = Checkbutton(timebtn, text="Enab", style="Disab.TCheckbutton", variable=TimeDisp, command=TimeCheckBox)
24179  ckb1.pack(side=LEFT)
24180  timelab = Label(timebtn, text="Time Plot")
24181  timelab.pack(side=LEFT)
24182  nextrow = nextrow + 1
24183  if EnablePhaseAnalizer > 0:
24184  phasebtn = Frame( frame1 )
24185  phasebtn.grid(row=nextrow, column=0, sticky=W)
24186  OOTphckb = Checkbutton(phasebtn, text="Enab", style="Disab.TCheckbutton", variable=PhADisp, command=PhACheckBox)
24187  OOTphckb.pack(side=LEFT)
24188  OOTBuildPhAScreen = Button(phasebtn, text="Phasor Plot", style="W11.TButton", command=MakePhAWindow)
24189  OOTBuildPhAScreen.pack(side=LEFT)
24190  nextrow = nextrow + 1
24191  #
24192  if EnableSpectrumAnalizer > 0:
24193  freqbtn = Frame( frame1 )
24194  freqbtn.grid(row=nextrow, column=0, sticky=W)
24195  OOTckb3 = Checkbutton(freqbtn, text="Enab", style="Disab.TCheckbutton", variable=FreqDisp, command=FreqCheckBox)
24196  OOTckb3.pack(side=LEFT)
24197  OOTBuildSpectrumScreen = Button(freqbtn, text="Spectrum Plot", style="W11.TButton", command=MakeSpectrumWindow)
24198  OOTBuildSpectrumScreen.pack(side=LEFT)
24199  nextrow = nextrow + 1
24200  #
24201  if EnableBodePlotter > 0:
24202  bodebtn = Frame( frame1 )
24203  bodebtn.grid(row=nextrow, column=0, sticky=W)
24204  OOTckb5 = Checkbutton(bodebtn, text="Enab", style="Disab.TCheckbutton", variable=BodeDisp, command=BodeCheckBox)
24205  OOTckb5.pack(side=LEFT)
24206  OOTBuildBodeScreen = Button(bodebtn, text="Bode Plot", style="W11.TButton", command=MakeBodeWindow)
24207  OOTBuildBodeScreen.pack(side=LEFT)
24208  nextrow = nextrow + 1
24209  #
24210  if EnableImpedanceAnalizer > 0:
24211  impdbtn = Frame( frame1 )
24212  impdbtn.grid(row=nextrow, column=0, sticky=W)
24213  OOTckb4 = Checkbutton(impdbtn, text="Enab", style="Disab.TCheckbutton", variable=IADisp, command=IACheckBox)
24214  OOTckb4.pack(side=LEFT)
24215  OOTBuildIAScreen = Button(impdbtn, text="Impedance", style="W11.TButton", command=MakeIAWindow)
24216  OOTBuildIAScreen.pack(side=LEFT)
24217  nextrow = nextrow + 1
24218  #
24219  if EnableOhmMeter > 0:
24220  dcohmbtn = Frame( frame1 )
24221  dcohmbtn.grid(row=nextrow, column=0, sticky=W)
24222  OOTckb6 = Checkbutton(dcohmbtn, text="Enab", style="Disab.TCheckbutton", variable=OhmDisp, command=OhmCheckBox)
24223  OOTckb6.pack(side=LEFT)
24224  OOTBuildOhmScreen = Button(dcohmbtn, text="Ohmmeter", style="W11.TButton", command=MakeOhmWindow)
24225  OOTBuildOhmScreen.pack(side=LEFT)
24226  nextrow = nextrow + 1
24227 
24228  if EnableDigIO > 0:
24229  OOTBuildDigScreen = Button(frame1, text="Digital I/O Screen", style="W17.TButton", command=MakeDigScreen)
24230  OOTBuildDigScreen.grid(row=nextrow, column=0, sticky=W)
24231  nextrow = nextrow + 1
24232  # Optional plugin tools
24233  if EnablePIODACMode > 0:
24234  OOTBuildDacScreen = Button(frame1, text="PIO-DAC Screen", style="W17.TButton", command=MakeDacScreen)
24235  OOTBuildDacScreen.grid(row=nextrow, column=0, sticky=W)
24236  nextrow = nextrow + 1
24237  if EnableMuxMode > 0:
24238  OOTBuildMuxScreen = Button(frame1, text="Analog In Mux Screen", style="W17.TButton", command=MakeMuxModeWindow)
24239  OOTBuildMuxScreen.grid(row=nextrow, column=0, sticky=W)
24240  nextrow = nextrow + 1
24241  if EnableMinigenMode > 0:
24242  OOTBuildMinigenScreen = Button(frame1, text="AD983x DDS Screen", style="W17.TButton", command=MakeMinigenWindow)
24243  OOTBuildMinigenScreen.grid(row=nextrow, column=0, sticky=W)
24244  nextrow = nextrow + 1
24245  if EnablePmodDA1Mode > 0:
24246  OOTBuildDA1Screen = Button(frame1, text="PMOD DA1 Screen", style="W17.TButton", command=MakeDA1Window)
24247  OOTBuildDA1Screen.grid(row=nextrow, column=0, sticky=W)
24248  nextrow = nextrow + 1
24249  if EnableDigPotMode >0:
24250  OOTBuildDigPotScreen = Button(frame1, text="Dig Pot Screen", style="W17.TButton", command=MakeDigPotWindow)
24251  OOTBuildDigPotScreen.grid(row=nextrow, column=0, sticky=W)
24252  nextrow = nextrow + 1
24253  if EnableGenericSerialMode >0:
24254  OOTGenericSerialScreen = Button(frame1, text="Generic Serial Output", style="W17.TButton", command=MakeGenericSerialWindow)
24255  OOTGenericSerialScreen.grid(row=nextrow, column=0, sticky=W)
24256  nextrow = nextrow + 1
24257  if EnableAD5626SerialMode >0:
24258  OOTAD5626SerialScreen = Button(frame1, text="AD5626 Output", style="W17.TButton", command=MakeAD5626Window)
24259  OOTAD5626SerialScreen.grid(row=nextrow, column=0, sticky=W)
24260  nextrow = nextrow + 1
24261  if EnableDigitalFilter >0:
24262  OOTDigFiltScreen = Button(frame1, text="Digital Filter", style="W17.TButton", command=MakeDigFiltWindow)
24263  OOTDigFiltScreen.grid(row=nextrow, column=0, sticky=W)
24264  nextrow = nextrow + 1
24265  if EnableCommandInterface > 0:
24266  OOTCommandLineScreen = Button(frame1, text="Command Interface", style="W17.TButton", command=MakeCommandScreen)
24267  OOTCommandLineScreen.grid(row=nextrow, column=0, sticky=W)
24268  nextrow = nextrow + 1
24269  if EnableMeasureScreen > 0:
24270  OOTMeasureScreen = Button(frame1, text="Measure Screen", style="W17.TButton", command=MakeMeasureScreen)
24271  OOTMeasureScreen.grid(row=nextrow, column=0, sticky=W)
24272  nextrow = nextrow + 1
24273  if EnableETSScreen > 0:
24274  OOTETSScreen = Button(frame1, text="ETS Controls", style="W17.TButton", command=MakeETSWindow)
24275  OOTETSScreen.grid(row=nextrow, column=0, sticky=W)
24276  nextrow = nextrow + 1
24277  #
24278  OOTdismissclbutton = Button(frame1, text="Dismiss", style="W8.TButton", command=DestroyOOTwindow)
24279  OOTdismissclbutton.grid(row=nextrow, column=0, sticky=W, pady=7)
24280 #
24281 def DestroyOOTwindow():
24282  global OOTwindow, OOTScreenStatus
24283 
24284  OOTScreenStatus.set(0)
24285  OOTwindow.destroy()
24286 #
24287 #
24288 # ================ Make main Screen ==========================
24289 TgInput = IntVar(0) # Trigger Input variable
24290 SingleShot = IntVar(0) # variable for single shot triger
24291 ManualTrigger = IntVar(0) # variable for Manual trigger
24292 AutoLevel = IntVar(0) # variable for Auto Level trigger at mid point
24293 ShowC1_V = IntVar(0) # curves to display variables
24294 TgEdge = IntVar(0) # Trigger edge variable
24295 # Show channels variables
24296 ShowC1_V = IntVar(0) # curves to display variables
24297 ShowC1_I = IntVar(0)
24298 ShowC2_V = IntVar(0)
24299 ShowC2_I = IntVar(0)
24300 ShowAV_I = IntVar(0)
24301 ShowBV_I = IntVar(0)
24302 ShowRA_V = IntVar(0)
24303 ShowRA_I = IntVar(0)
24304 ShowRB_V = IntVar(0)
24305 ShowRB_I = IntVar(0)
24306 ShowMath = IntVar(0)
24307 ShowPB_A = IntVar(0)
24308 ShowPB_B = IntVar(0)
24309 ShowPB_C = IntVar(0)
24310 ShowPB_D = IntVar(0)
24311 # Bode and SA variables
24312 ShowC1_VdB = IntVar(0) # curves to display variables
24313 ShowC1_P = IntVar(0)
24314 ShowC2_VdB = IntVar(0)
24315 ShowC2_P = IntVar(0)
24316 ShowMarker = IntVar(0)
24317 ShowRA_VdB = IntVar(0)
24318 ShowRA_P = IntVar(0)
24319 ShowRB_VdB = IntVar(0)
24320 ShowRB_P = IntVar(0)
24321 ShowMathSA = IntVar(0)
24322 ShowRMath = IntVar(0)
24323 ShowAWGASA = IntVar(0)
24324 ShowAWGBSA = IntVar(0)
24325 HScaleBP = IntVar(0)
24326 HScaleBP.set(1)
24327 #
24328 Show_MathX = IntVar(0)
24329 Show_MathY = IntVar(0)
24330 AutoCenterA = IntVar(0)
24331 AutoCenterB = IntVar(0)
24332 SmoothCurves = IntVar(0)
24333 ZOHold = IntVar(0)
24334 TRACEmodeTime = IntVar(0)
24335 TRACEmodeTime.set(0)
24336 DecimateOption = IntVar(0)
24337 MathTrace = IntVar(0)
24338 # AWG variables
24339 AWGAMode = IntVar(0) # AWG A mode variable
24340 AWGAIOMode = IntVar(0) # AWG A Split I/O mode variable
24341 AWGATerm = IntVar(0) # AWG A termination variable
24342 AWGAShape = IntVar(0) # AWG A Wave shape variable
24343 AWGAPhaseDelay = IntVar(0) #
24344 AWGARepeatFlag = IntVar(0) # AWG A Arb shape repeat flag
24345 AWGABurstFlag = IntVar(0) # AWG A Burst mode flag
24346 AWGBBurstFlag = IntVar(0) # AWG B Burst mode flag
24347 AWGBMode = IntVar(0) # AWG B mode variable
24348 AWGBIOMode = IntVar(0) # AWG B Split I/O mode variable
24349 AWGBTerm = IntVar(0) # AWG B termination variable
24350 AWGBShape = IntVar(0) # AWG B Wave shape variable
24351 AWGBPhaseDelay = IntVar(0) #
24352 AWGBRepeatFlag = IntVar(0) # AWG B Arb shape repeat flag
24353 AWGAMode.set(2)
24354 AWGBMode.set(2)
24355 AWGSync = IntVar(0) # Sync start both AWG channels
24356 AWGSync.set(1)
24357 BisCompA = IntVar(0) # Make Channel B comp of channel A
24358 BisCompA.set(0)
24359 # define vertical measurment variables
24360 MeasDCV1 = IntVar(0)
24361 MeasMinV1 = IntVar(0)
24362 MeasMaxV1 = IntVar(0)
24363 MeasMidV1 = IntVar(0)
24364 MeasPPV1 = IntVar(0)
24365 MeasRMSV1 = IntVar(0)
24366 MeasRMSVA_B = IntVar(0)
24367 MeasDCI1 = IntVar(0)
24368 MeasMinI1 = IntVar(0)
24369 MeasMaxI1 = IntVar(0)
24370 MeasMidI1 = IntVar(0)
24371 MeasPPI1 = IntVar(0)
24372 MeasRMSI1 = IntVar(0)
24373 MeasDiffAB = IntVar(0)
24374 MeasDCV2 = IntVar(0)
24375 MeasMinV2 = IntVar(0)
24376 MeasMaxV2 = IntVar(0)
24377 MeasMidV2 = IntVar(0)
24378 MeasPPV2 = IntVar(0)
24379 MeasRMSV2 = IntVar(0)
24380 MeasDCI2 = IntVar(0)
24381 MeasMinI2 = IntVar(0)
24382 MeasMaxI2 = IntVar(0)
24383 MeasMidI2 = IntVar(0)
24384 MeasPPI2 = IntVar(0)
24385 MeasRMSI2 = IntVar(0)
24386 MeasDiffBA = IntVar(0)
24387 MeasUserA = IntVar(0)
24388 MeasAHW = IntVar(0)
24389 MeasALW = IntVar(0)
24390 MeasADCy = IntVar(0)
24391 MeasAPER = IntVar(0)
24392 MeasAFREQ = IntVar(0)
24393 MeasBHW = IntVar(0)
24394 MeasBLW = IntVar(0)
24395 MeasBDCy = IntVar(0)
24396 MeasBPER = IntVar(0)
24397 MeasBFREQ = IntVar(0)
24398 MeasPhase = IntVar(0)
24399 MeasTopV1 = IntVar(0)
24400 MeasBaseV1 = IntVar(0)
24401 MeasTopV2 = IntVar(0)
24402 MeasBaseV2 = IntVar(0)
24403 MeasUserB = IntVar(0)
24404 MeasDelay = IntVar(0)
24405 TimeDisp = IntVar(0)
24406 TimeDisp.set(1)
24407 XYDisp = IntVar(0)
24408 FreqDisp = IntVar(0)
24409 PhADisp = IntVar(0)
24410 BodeDisp = IntVar(0)
24411 IADisp = IntVar(0)
24412 OhmDisp = IntVar(0)
24413 OOTScreenStatus = IntVar(0)
24414 OOTScreenStatus.set(0)
24415 PhAScreenStatus = IntVar(0)
24416 PhAScreenStatus.set(0)
24417 AppendPhAData = IntVar(0)
24418 AppendPhAData.set(0)
24419 PhAPlotMode = IntVar(0)
24420 PhADatafilename = "PhaseData.csv"
24421 BodeScreenStatus = IntVar(0)
24422 BodeScreenStatus.set(0)
24423 DigScreenStatus = IntVar(0)
24424 DigScreenStatus.set(0)
24425 DacScreenStatus = IntVar(0)
24426 DacScreenStatus.set(0)
24427 MuxScreenStatus = IntVar(0)
24428 MuxScreenStatus.set(0)
24429 MuxEnb = IntVar(0)
24430 MuxSync = IntVar(0)
24431 DualMuxMode = IntVar(0)
24432 ChopMuxMode = IntVar(0)
24433 ChopTrig = IntVar(0)
24434 MinigenScreenStatus = IntVar(0)
24435 MinigenScreenStatus.set(0)
24436 DA1ScreenStatus = IntVar(0)
24437 DA1ScreenStatus.set(0)
24438 DigPotScreenStatus = IntVar(0)
24439 DigPotScreenStatus.set(0)
24440 GenericSerialStatus = IntVar(0)
24441 GenericSerialStatus.set(0)
24442 AD5626SerialStatus = IntVar(0)
24443 AD5626SerialStatus.set(0)
24444 DigFiltStatus = IntVar(0)
24445 DigFiltStatus.set(0)
24446 CommandStatus = IntVar(0)
24447 CommandStatus.set(0)
24448 MeasureStatus = IntVar(0)
24449 MeasureStatus.set(0)
24450 MarkerScale = IntVar(0)
24451 MarkerScale.set(1)
24452 SettingsStatus = IntVar(0)
24453 CHA_RC_HP = IntVar(0)
24454 CHB_RC_HP = IntVar(0)
24455 CHAI_RC_HP = IntVar(0)
24456 CHBI_RC_HP = IntVar(0)
24457 HScale = IntVar(0)
24458 SAVScale = IntVar(0)
24459 SAVPSD = IntVar(0)
24460 SAvertmax = 1.0
24461 SAvertmin = 1.0E-6
24462 #
24463 if GUITheme == "Light": # Can be Light or Dark or Blue or LtBlue
24464  FrameBG = "#d7d7d7"
24465  ButtonText = "#000000"
24466 elif GUITheme == "Dark":
24467  FrameBG = "#484848"
24468  ButtonText = "#ffffff"
24469 elif GUITheme == "Blue":
24470  FrameBG = "#242468"
24471  ButtonText = "#d0d0ff"
24472 elif GUITheme == "LtBlue":
24473  FrameBG = "#c0e8ff"
24474  ButtonText = "#000040"
24475 EntryText = "#000000"
24476 BoxColor = "#0000ff" # 100% blue
24477 root.style.configure("TFrame", background=FrameBG, borderwidth=BorderSize)
24478 root.style.configure("TLabelframe", background=FrameBG)
24479 root.style.configure("TLabel", foreground=ButtonText, background=FrameBG, relief=LabRelief)
24480 root.style.configure("TEntry", foreground=EntryText, background=FrameBG, relief=ButRelief) #cursor='sb_v_double_arrow'
24481 root.style.configure("TCheckbutton", foreground=ButtonText, background=FrameBG, indicatorcolor=FrameBG)
24482 root.style.configure("TRadiobutton", foreground=ButtonText, background=FrameBG, indicatorcolor=FrameBG)
24483 root.style.configure("TButton", foreground=ButtonText, background=FrameBG, highlightcolor=FrameBG, relief=ButRelief)
24484 # define custom buttons and labels
24485 root.style.configure("TSpinbox", arrowsize=SBoxarrow) # 11 only changes things in Python 3
24486 root.style.configure("W3.TButton", width=3, relief=ButRelief)
24487 root.style.configure("W4.TButton", width=4, relief=ButRelief)
24488 root.style.configure("W5.TButton", width=5, relief=ButRelief)
24489 root.style.configure("W6.TButton", width=6, relief=ButRelief)
24490 root.style.configure("W7.TButton", width=7, relief=ButRelief)
24491 root.style.configure("W8.TButton", width=8, relief=ButRelief)
24492 root.style.configure("W9.TButton", width=9, relief=ButRelief)
24493 root.style.configure("W10.TButton", width=10, relief=ButRelief)
24494 root.style.configure("W11.TButton", width=11, relief=ButRelief)
24495 root.style.configure("W16.TButton", width=16, relief=ButRelief)
24496 root.style.configure("W17.TButton", width=17, relief=ButRelief)
24497 root.style.configure("Stop.TButton", background=ButtonRed, foreground="#000000", width=4, relief=ButRelief)
24498 root.style.configure("Run.TButton", background=ButtonGreen, foreground="#000000", width=4, relief=ButRelief)
24499 root.style.configure("Pwr.TButton", background=ButtonGreen, foreground="#000000", width=8, relief=ButRelief)
24500 root.style.configure("PwrOff.TButton", background=ButtonRed, foreground="#000000", width=8, relief=ButRelief)
24501 root.style.configure("Roll.TButton", background=ButtonGreen, foreground="#000000", width=7, relief=ButRelief)
24502 root.style.configure("RollOff.TButton", background=ButtonRed, foreground="#000000", width=8, relief=ButRelief)
24503 root.style.configure("RConn.TButton", background=ButtonRed, foreground="#000000", width=5, relief=ButRelief)
24504 root.style.configure("GConn.TButton", background=ButtonGreen, foreground="#000000", width=5, relief=ButRelief)
24505 root.style.configure("Rtrace1.TButton", background=COLORtrace1, foreground="#000000", width=7, relief=RAISED)
24506 root.style.configure("Strace1.TButton", background=COLORtrace1, foreground="#000000", width=7, relief=SUNKEN)
24507 root.style.configure("Ctrace1.TButton", background=COLORtrace1, foreground="#000000", relief=ButRelief)
24508 root.style.configure("Rtrace2.TButton", background=COLORtrace2, foreground="#000000", width=7, relief=RAISED)
24509 root.style.configure("Strace2.TButton", background=COLORtrace2, foreground="#000000", width=7, relief=SUNKEN)
24510 root.style.configure("Ctrace2.TButton", background=COLORtrace2, foreground="#000000", relief=ButRelief)
24511 root.style.configure("Rtrace3.TButton", background=COLORtrace3, foreground="#000000", width=7, relief=RAISED)
24512 root.style.configure("Strace3.TButton", background=COLORtrace3, foreground="#000000", width=7, relief=SUNKEN)
24513 root.style.configure("Ctrace3.TButton", background=COLORtrace3, foreground="#000000", relief=ButRelief)
24514 root.style.configure("Rtrace4.TButton", background=COLORtrace4, foreground="#000000", width=7, relief=RAISED)
24515 root.style.configure("Strace4.TButton", background=COLORtrace4, foreground="#000000", width=7, relief=SUNKEN)
24516 root.style.configure("Ctrace4.TButton", background=COLORtrace4, foreground="#000000", relief=ButRelief)
24517 root.style.configure("Rtrace6.TButton", background=COLORtrace6, foreground="#000000", width=7, relief=RAISED)
24518 root.style.configure("Strace6.TButton", background=COLORtrace6, foreground="#000000", width=7, relief=SUNKEN)
24519 root.style.configure("Rtrace7.TButton", background=COLORtrace7, foreground="#000000", width=7, relief=RAISED)
24520 root.style.configure("Strace7.TButton", background=COLORtrace7, foreground="#000000", width=7, relief=SUNKEN)
24521 root.style.configure("T1W16.TButton", background=COLORtrace1, width=16, relief=ButRelief)
24522 root.style.configure("T2W16.TButton", background=COLORtrace2, width=16, relief=ButRelief)
24523 root.style.configure("T3W16.TButton", background=COLORtrace3, width=16, relief=ButRelief)
24524 root.style.configure("T4W16.TButton", background=COLORtrace4, width=16, relief=ButRelief)
24525 root.style.configure("T5W16.TButton", background=COLORtrace5, width=16, relief=ButRelief)
24526 root.style.configure("T6W16.TButton", background=COLORtrace6, width=16, relief=ButRelief)
24527 root.style.configure("T7W16.TButton", background=COLORtrace7, width=16, relief=ButRelief)
24528 root.style.configure("TR1W16.TButton", background=COLORtraceR1, width=16, relief=ButRelief)
24529 root.style.configure("TR2W16.TButton", background=COLORtraceR2, width=16, relief=ButRelief)
24530 root.style.configure("TR3W16.TButton", background=COLORtraceR3, width=16, relief=ButRelief)
24531 root.style.configure("TR4W16.TButton", background=COLORtraceR4, width=16, relief=ButRelief)
24532 root.style.configure("TR5W16.TButton", background=COLORtraceR5, width=16, relief=ButRelief)
24533 root.style.configure("TR6W16.TButton", background=COLORtraceR6, width=16, relief=ButRelief)
24534 root.style.configure("TR7W16.TButton", background=COLORtraceR7, width=16, relief=ButRelief)
24535 root.style.configure("TGW16.TButton", background=COLORtrigger, width=16, relief=ButRelief)
24536 root.style.configure("ZLW16.TButton", background=COLORzeroline, width=16, relief=ButRelief)
24537 root.style.configure("RGray.TButton", background="#808080", width=7, relief=RAISED)
24538 root.style.configure("SGray.TButton", background="#808080", width=7, relief=SUNKEN)
24539 #
24540 root.style.configure("A10T5.TLabelframe.Label", background=FrameBG, foreground=COLORtraceR5, font=('Arial', 10, 'bold'))
24541 root.style.configure("A10T5.TLabelframe", borderwidth=BorderSize, relief=FrameRefief)
24542 root.style.configure("A10T6.TLabelframe.Label", background=FrameBG, foreground=COLORtrace6, font=('Arial', 10, 'bold'))
24543 root.style.configure("A10T6.TLabelframe", borderwidth=BorderSize, relief=FrameRefief)
24544 root.style.configure("A10T7.TLabelframe.Label", background=FrameBG, foreground=COLORtrace7, font=('Arial', 10, 'bold'))
24545 root.style.configure("A10T7.TLabelframe", borderwidth=BorderSize, relief=FrameRefief)
24546 #
24547 root.style.configure("A10R1.TLabelframe.Label", background=FrameBG, foreground=COLORtraceR1, font=('Arial', 10, 'bold'))
24548 root.style.configure("A10R1.TLabelframe", borderwidth=BorderSize, relief=FrameRefief)
24549 root.style.configure("A10R2.TLabelframe.Label", background=FrameBG, foreground=COLORtraceR2, font=('Arial', 10, 'bold'))
24550 root.style.configure("A10R2.TLabelframe", borderwidth=BorderSize, relief=FrameRefief)
24551 root.style.configure("A10.TLabelframe.Label", background=FrameBG, font=('Arial', 10, 'bold'))
24552 root.style.configure("A10.TLabelframe", borderwidth=BorderSize, relief=FrameRefief)
24553 root.style.configure("A10B.TLabel", foreground=ButtonText, font="Arial 10 bold") # Black text
24554 root.style.configure("A10R.TLabel", foreground=ButtonRed, font="Arial 10 bold") # Red text
24555 root.style.configure("A10G.TLabel", foreground=ButtonGreen, font="Arial 10 bold") # Red text
24556 root.style.configure("A12B.TLabel", foreground=ButtonText, font="Arial 12 bold") # Black text
24557 root.style.configure("A16B.TLabel", foreground=ButtonText, font="Arial 16 bold") # Black text
24558 root.style.configure("Stop.TRadiobutton", background=ButtonRed, indicatorcolor=FrameBG)
24559 root.style.configure("Run.TRadiobutton", background=ButtonGreen, indicatorcolor=FrameBG)
24560 root.style.configure("Disab.TCheckbutton", foreground=ButtonText, background=FrameBG, indicatorcolor=ButtonRed)
24561 root.style.configure("Enab.TCheckbutton", foreground=ButtonText, background=FrameBG, indicatorcolor=ButtonGreen)
24562 root.style.configure("Strace1.TCheckbutton", background=COLORtrace1, foreground="#000000", indicatorcolor="#ffffff")
24563 root.style.configure("Strace2.TCheckbutton", background=COLORtrace2, foreground="#000000", indicatorcolor="#ffffff")
24564 root.style.configure("Strace3.TCheckbutton", background=COLORtrace3, foreground="#000000", indicatorcolor="#ffffff")
24565 root.style.configure("Strace4.TCheckbutton", background=COLORtrace4, foreground="#000000", indicatorcolor="#ffffff")
24566 root.style.configure("Strace6.TCheckbutton", background=COLORtrace6, foreground="#000000", indicatorcolor="#ffffff")
24567 root.style.configure("Strace7.TCheckbutton", background=COLORtrace7, foreground="#000000", indicatorcolor="#ffffff")
24568 root.style.configure("WPhase.TRadiobutton", width=5, foreground="#000000", background="white", indicatorcolor=("red", "green"))
24569 root.style.configure("GPhase.TRadiobutton", width=5, foreground="#000000", background="gray", indicatorcolor=("red", "green"))
24570 # Create frames
24571 frame2r = Frame(root, borderwidth=BorderSize, relief=FrameRefief)
24572 frame2r.pack(side=RIGHT, fill=BOTH, expand=NO)
24573 
24574 frame1 = Frame(root, borderwidth=BorderSize, relief=FrameRefief)
24575 frame1.pack(side=TOP, fill=BOTH, expand=NO)
24576 
24577 frame2 = Frame(root, borderwidth=BorderSize, relief=FrameRefief)
24578 frame2.pack(side=TOP, fill=BOTH, expand=YES)
24579 
24580 frame3 = Frame(root, borderwidth=BorderSize, relief=FrameRefief)
24581 frame3.pack(side=TOP, fill=BOTH, expand=NO)
24582 # create a pulldown menu
24583 # Trigger signals
24584 Triggermenu = Menubutton(frame1, text="Trigger", style="W7.TButton")
24585 Triggermenu.menu = Menu(Triggermenu, tearoff = 0 )
24586 Triggermenu["menu"] = Triggermenu.menu
24587 Triggermenu.menu.add_radiobutton(label='None', variable=TgInput, value=0)
24588 Triggermenu.menu.add_radiobutton(label='CA-V', variable=TgInput, value=1)
24589 Triggermenu.menu.add_radiobutton(label='CA-I', variable=TgInput, value=2)
24590 Triggermenu.menu.add_radiobutton(label='CB-V', variable=TgInput, value=3)
24591 Triggermenu.menu.add_radiobutton(label='CB-I', variable=TgInput, value=4)
24592 Triggermenu.menu.add_radiobutton(label='CA-V or CB-V', variable=TgInput, value=5)
24593 # Triggermenu.menu.add_radiobutton(label='Alternate A/B', variable=TgInput, value=6)
24594 Triggermenu.menu.add_checkbutton(label='Auto Level', variable=AutoLevel)
24595 Triggermenu.menu.add_checkbutton(label='Low Pass Filter', variable=LPFTrigger)
24596 Triggermenu.menu.add_checkbutton(label='Manual Trgger', variable=ManualTrigger)
24597 Triggermenu.menu.add_checkbutton(label='SingleShot', variable=SingleShot)
24598 Triggermenu.pack(side=LEFT)
24599 #
24600 Edgemenu = Menubutton(frame1, text="Edge", style="W5.TButton")
24601 Edgemenu.menu = Menu(Edgemenu, tearoff = 0 )
24602 Edgemenu["menu"] = Edgemenu.menu
24603 Edgemenu.menu.add_radiobutton(label='Rising (+)', variable=TgEdge, value=0)
24604 Edgemenu.menu.add_radiobutton(label='Falling (-)', variable=TgEdge, value=1)
24605 Edgemenu.pack(side=LEFT)
24606 #
24607 tlab = Label(frame1, text="Trig Level")
24608 tlab.pack(side=LEFT)
24609 TRIGGERentry = Entry(frame1, width=5, cursor='double_arrow')
24610 TRIGGERentry.bind('<MouseWheel>', onTextScroll)
24611 TRIGGERentry.bind("<Button-4>", onTextScroll)# with Linux OS
24612 TRIGGERentry.bind("<Button-5>", onTextScroll)
24613 TRIGGERentry.bind("<Return>", BTriglevel)
24614 TRIGGERentry.bind('<Key>', onTextKey)
24615 TRIGGERentry.pack(side=LEFT)
24616 TRIGGERentry.delete(0,"end")
24617 TRIGGERentry.insert(0,0.0)
24618 #
24619 tgb = Button(frame1, text="50%", style="W4.TButton", command=BTrigger50p)
24620 tgb.pack(side=LEFT)
24621 #
24622 hldlab = Button(frame1, text="Hold Off", style="W8.TButton", command=IncHoldOff)
24623 hldlab.pack(side=LEFT)
24624 HoldOffentry = Entry(frame1, width=4, cursor='double_arrow')
24625 HoldOffentry.bind('<MouseWheel>', onTextScroll)
24626 HoldOffentry.bind("<Button-4>", onTextScroll)# with Linux OS
24627 HoldOffentry.bind("<Button-5>", onTextScroll)
24628 HoldOffentry.bind("<Return>", BHoldOff)
24629 HoldOffentry.bind('<Key>', onTextKey)
24630 HoldOffentry.pack(side=LEFT)
24631 HoldOffentry.delete(0,"end")
24632 HoldOffentry.insert(0,0.0)
24633 #
24634 hozlab = Button(frame1, text="Horz Pos", style="W8.TButton", command=SetTriggerPoss)
24635 hozlab.pack(side=LEFT)
24636 HozPossentry = Entry(frame1, width=4, cursor='double_arrow')
24637 HozPossentry.bind('<MouseWheel>', onTextScroll)
24638 HozPossentry.bind("<Button-4>", onTextScroll)# with Linux OS
24639 HozPossentry.bind("<Button-5>", onTextScroll)
24640 HozPossentry.bind("<Return>", BHozPoss)
24641 HozPossentry.bind('<Key>', onTextKey)
24642 HozPossentry.pack(side=LEFT)
24643 HozPossentry.delete(0,"end")
24644 HozPossentry.insert(0,0.0)
24645 #
24646 bexit = Button(frame1, text="Exit", style="W4.TButton", command=Bcloseexit)
24647 bexit.pack(side=RIGHT)
24648 bstop = Button(frame1, text="Stop", style="Stop.TButton", command=BStop)
24649 bstop.pack(side=RIGHT)
24650 brun = Button(frame1, text="Run", style="Run.TButton", command=BStart)
24651 brun.pack(side=RIGHT)
24652 PwrBt = Button(frame1, text="PWR-ON", style="Pwr.TButton", command=BPower)
24653 PwrBt.pack(side=RIGHT)
24654 # Curves Menu
24655 if EnableScopeOnly == 0:
24656  Showmenu = Menubutton(frame1, text="Curves", style="W7.TButton")
24657 else:
24658  Showmenu = Menubutton(frame1, text="Traces", style="W7.TButton")
24659 Showmenu.menu = Menu(Showmenu, tearoff = 0 )
24660 Showmenu["menu"] = Showmenu.menu
24661 Showmenu.menu.add_command(label="-Show Traces-", foreground="blue", command=donothing)
24662 Showmenu.menu.add_command(label="All", command=BShowCurvesAll)
24663 Showmenu.menu.add_command(label="None", command=BShowCurvesNone)
24664 Showmenu.menu.add_checkbutton(label='CA-V (1)', background=COLORtrace1, variable=ShowC1_V, command=TraceSelectADC_Mux)
24665 Showmenu.menu.add_checkbutton(label='CA-I (3)', background=COLORtrace3, variable=ShowC1_I, command=TraceSelectADC_Mux)
24666 Showmenu.menu.add_checkbutton(label='CB-V (2)', background=COLORtrace2, variable=ShowC2_V, command=TraceSelectADC_Mux)
24667 Showmenu.menu.add_checkbutton(label='CB-I (4)', background=COLORtrace4, variable=ShowC2_I, command=TraceSelectADC_Mux)
24668 Showmenu.menu.add_checkbutton(label='Math-X', background=COLORtrace6, variable=Show_MathX, command=UpdateTimeTrace)
24669 Showmenu.menu.add_checkbutton(label='Math-Y', background=COLORtrace7, variable=Show_MathY, command=UpdateTimeTrace)
24670 Showmenu.menu.add_command(label="-Auto Vert Center-", foreground="blue", command=donothing)
24671 Showmenu.menu.add_checkbutton(label='Center CA-V', variable=AutoCenterA)
24672 Showmenu.menu.add_checkbutton(label='Center CB-V', variable=AutoCenterB)
24673 Showmenu.menu.add_command(label="-Input HP Comp-", foreground="blue", command=donothing)
24674 Showmenu.menu.add_checkbutton(label='Comp CA-V', variable=CHA_RC_HP)
24675 Showmenu.menu.add_checkbutton(label='Comp CB-V', variable=CHB_RC_HP)
24676 if EnableHSsampling > 0:
24677  Showmenu.menu.add_checkbutton(label='Comp CA-I', variable=CHAI_RC_HP)
24678  Showmenu.menu.add_checkbutton(label='Comp CB-I', variable=CHBI_RC_HP)
24679 Showmenu.menu.add_separator()
24680 Showmenu.menu.add_checkbutton(label='RA-V', background=COLORtraceR1, variable=ShowRA_V, command=UpdateTimeTrace)
24681 Showmenu.menu.add_checkbutton(label='RA-I', background=COLORtraceR3, variable=ShowRA_I, command=UpdateTimeTrace)
24682 Showmenu.menu.add_checkbutton(label='RB-V', background=COLORtraceR2, variable=ShowRB_V, command=UpdateTimeTrace)
24683 Showmenu.menu.add_checkbutton(label='RB-I', background=COLORtraceR4, variable=ShowRB_I, command=UpdateTimeTrace)
24684 Showmenu.menu.add_checkbutton(label='RMath', background=COLORtraceR5, variable=ShowMath, command=UpdateTimeTrace)
24685 Showmenu.menu.add_separator()
24686 Showmenu.menu.add_checkbutton(label='T Cursor (t)', variable=ShowTCur, command=UpdateTimeTrace)
24687 Showmenu.menu.add_checkbutton(label='V Cursor (v)', variable=ShowVCur, command=UpdateTimeTrace)
24688 Showmenu.pack(side=RIGHT)
24689 #
24690 if ShowBallonHelp > 0:
24691  Triggermenu_tip = CreateToolTip(Triggermenu, 'Select trigger signal')
24692  Edgemenu_tip = CreateToolTip(Edgemenu, 'Select trigger edge')
24693  tgb_tip = CreateToolTip(tgb, 'Set trigger level to waveform mid point')
24694  hldlab_tip = CreateToolTip(hldlab, 'Increment Hold Off setting by one time division')
24695  hozlab_tip = CreateToolTip(hozlab, 'When triggering, set trigger point to center of screen')
24696  bexit_tip = CreateToolTip(bexit, 'Exit ALICE Desktop')
24697  bstop_tip = CreateToolTip(bstop, 'Stop acquiring data')
24698  brun_tip = CreateToolTip(brun, 'Start acquiring data')
24699  pwrbt_tip = CreateToolTip(PwrBt, 'Toggle ext power supply')
24700  Showmenu_tip = CreateToolTip(Showmenu, 'Select which traces to display')
24701 
24702 # Sampling controls Widgets
24703 if EnableHSsampling > 0:
24704  fminlab2 = Label(frame1, text="KHz")
24705  fminlab2.pack(side=RIGHT)
24706  FminEntry = Entry(frame1, width=6, cursor='double_arrow')
24707  FminEntry.bind('<MouseWheel>', onFminScroll)
24708  FminEntry.bind("<Button-4>", onFminScroll)# with Linux OS
24709  FminEntry.bind("<Button-5>", onFminScroll)
24710  FminEntry.bind("<Return>", SetAD9833)
24711  FminEntry.pack(side=RIGHT)
24712  FminEntry.delete(0,"end")
24713  FminEntry.insert(0,25)
24714  fminlab = Button(frame1, text="Fmin", style="W5.TButton", command=BSetFmin)
24715  fminlab.pack(side=RIGHT)
24716  #
24717  HtMulEntry = Entry(frame1, width=4, cursor='double_arrow')
24718  HtMulEntry.bind('<MouseWheel>', onMulXScroll)
24719  HtMulEntry.bind("<Button-4>", onMulXScroll)# with Linux OS
24720  HtMulEntry.bind("<Button-5>", onMulXScroll)
24721  HtMulEntry.bind("<Return>", SetAD9833)
24722  HtMulEntry.pack(side=RIGHT)
24723  HtMulEntry.delete(0,"end")
24724  HtMulEntry.insert(0,1)
24725  mulxlab = Label( frame1, text = "Mul X")
24726  mulxlab.pack(side=RIGHT)
24727 else:
24728  RollBt = Button(frame1, text="Roll-Off", style="RollOff.TButton", command=BRoll)
24729  RollBt.pack(side=RIGHT)
24730 #
24731 # Time per Div
24732 TMsb = Spinbox(frame1, width=5, values= TMpdiv, cursor='double_arrow', command=BTime)
24733 TMsb.bind('<MouseWheel>', onSpinBoxScroll)
24734 TMsb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
24735 TMsb.bind("<Button-5>", onSpinBoxScroll)
24736 TMsb.pack(side=RIGHT)
24737 TMsb.delete(0,"end")
24738 TMsb.insert(0,0.5)
24739 TMlab = Label(frame1, text="Time mS/Div")
24740 TMlab.pack(side=RIGHT)
24741 #
24742 ca = Canvas(frame2, width=CANVASwidth, height=CANVASheight, background=COLORcanvas, cursor='cross')
24743 # add mouse left and right button click to canvas
24744 ca.bind('<Configure>', CAresize)
24745 ca.bind('<1>', onCanvasClickLeft)
24746 ca.bind('<3>', onCanvasClickRight)
24747 ca.bind("<Motion>",onCanvasMouse_xy)
24748 ca.bind("<Up>", onCanvasUpArrow) # DoNothing)
24749 ca.bind("<Down>", onCanvasDownArrow)
24750 ca.bind("<Left>", onCanvasLeftArrow)
24751 ca.bind("<Right>", onCanvasRightArrow)
24752 ca.bind("<space>", onCanvasSpaceBar)
24753 ca.bind("1", onCanvasOne)
24754 ca.bind("2", onCanvasTwo)
24755 ca.bind("3", onCanvasThree)
24756 ca.bind("4", onCanvasFour)
24757 ca.bind("5", onCanvasFive)
24758 ca.bind("6", onCanvasSix)
24759 ca.bind("7", onCanvasSeven)
24760 ca.bind("8", onCanvasEight)
24761 ca.bind("9", onCanvasNine)
24762 ca.bind("0", onCanvasZero)
24763 ca.bind("a", onCanvasAverage)
24764 ca.bind("t", onCanvasShowTcur)
24765 ca.bind("v", onCanvasShowVcur)
24766 ca.bind("s", onCanvasSnap)
24767 ca.bind("+", onCanvasTrising)
24768 ca.bind("-", onCanvasTfalling)
24769 ca.bind('<MouseWheel>', onCanvasClickScroll)
24770 ca.bind("<Button-4>", onCanvasClickScroll)# with Linux OS
24771 ca.bind("<Button-5>", onCanvasClickScroll)
24772 ca.pack(side=TOP, fill=BOTH, expand=YES)
24773 MouseWidget = ca
24774 # right side menu buttons
24775 dropmenu = Frame( frame2r )
24776 dropmenu.pack(side=TOP)
24777 bcon = Button(dropmenu, text="Recon", style="RConn.TButton", command=ConnectDevice)
24778 bcon.pack(side=LEFT, anchor=W)
24779 # File menu
24780 Filemenu = Menubutton(dropmenu, text="File", style="W4.TButton")
24781 Filemenu.menu = Menu(Filemenu, tearoff = 0 )
24782 Filemenu["menu"] = Filemenu.menu
24783 Filemenu.menu.add_command(label="Save Config", command=BSaveConfigTime)
24784 Filemenu.menu.add_command(label="Load Config", command=BLoadConfigTime)
24785 Filemenu.menu.add_command(label="Run Script", command=RunScript)
24786 Filemenu.menu.add_command(label="Save Adj", command=BSaveCal)
24787 Filemenu.menu.add_command(label="Load Adj", command=BLoadCal)
24788 Filemenu.menu.add_command(label="Save Screen", command=BSaveScreen)
24789 Filemenu.menu.add_command(label="Save To CSV", command=BSaveData)
24790 Filemenu.menu.add_command(label="Load From CSV", command=BReadData)
24791 Filemenu.menu.add_command(label="Save PWL Data", command=BSaveChannelData)
24792 Filemenu.menu.add_command(label="Help", command=BHelp)
24793 Filemenu.menu.add_command(label="About", command=BAbout)
24794 Filemenu.pack(side=LEFT, anchor=W)
24795 # Options Menu
24796 Optionmenu = Menubutton(dropmenu, text="Options", style="W7.TButton")
24797 Optionmenu.menu = Menu(Optionmenu, tearoff = 0 )
24798 Optionmenu["menu"] = Optionmenu.menu
24799 Optionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
24800 Optionmenu.menu.add_command(label='Set Sample Rate', command=MakeSampleRateMenu) # SetSampleRate)
24801 Optionmenu.menu.add_checkbutton(label='Smooth', variable=SmoothCurves, command=UpdateTimeTrace)
24802 Optionmenu.menu.add_checkbutton(label='Z-O-Hold', variable=ZOHold, command=UpdateTimeTrace)
24803 Optionmenu.menu.add_checkbutton(label='Decimate', variable=DecimateOption)
24804 Optionmenu.menu.add_checkbutton(label='Gated Meas', variable=MeasGateStatus)
24805 Optionmenu.menu.add_checkbutton(label='Trace Avg (a)', variable=TRACEmodeTime)
24806 Optionmenu.menu.add_checkbutton(label='Persistance', variable=ScreenTrefresh)
24807 Optionmenu.menu.add_command(label='Set Marker Location', command=BSetMarkerLocation)
24808 Optionmenu.menu.add_command(label='Change Plot Label', command=BUserCustomPlotText)
24809 Optionmenu.menu.add_command(label="SnapShot (s)", command=BSnapShot)
24810 Optionmenu.menu.add_command(label="Color Selector", command=ColorSelector)
24811 Optionmenu.menu.add_radiobutton(label='Black BG', variable=ColorMode, value=0, command=BgColor)
24812 Optionmenu.menu.add_radiobutton(label='White BG', variable=ColorMode, value=1, command=BgColor)
24813 Optionmenu.menu.add_command(label="Run Self Cal", command=SelfCalibration)
24814 if EnableScopeOnly != 0:
24815  Optionmenu.menu.add_command(label="Open Instruments", command=OpenOtherTools)
24816 if AllowFlashFirmware == 1:
24817  Optionmenu.menu.add_command(label="Save Cal Settings", command=Save_Cal_file)
24818  Optionmenu.menu.add_command(label="Update Firmware", command=UpdateFirmware)
24819 Optionmenu.pack(side=LEFT, anchor=W)
24820 #
24821 dropmenu2 = Frame( frame2r )
24822 dropmenu2.pack(side=TOP)
24823 # Open Math trace menu
24824 mathbt = Button(dropmenu2, text="Math", style="W4.TButton", command = NewEnterMathControls)
24825 mathbt.pack(side=RIGHT, anchor=W)
24826 # Measurments menu
24827 measlab = Label(dropmenu2, text="Meas")
24828 measlab.pack(side=LEFT, anchor=W)
24829 MeasmenuA = Menubutton(dropmenu2, text="CA", style="W3.TButton")
24830 MeasmenuA.menu = Menu(MeasmenuA, tearoff = 0 )
24831 MeasmenuA["menu"] = MeasmenuA.menu
24832 MeasmenuA.menu.add_command(label="-CA-V-", foreground="blue", command=donothing)
24833 MeasmenuA.menu.add_checkbutton(label='Avg', variable=MeasDCV1)
24834 MeasmenuA.menu.add_checkbutton(label='Min', variable=MeasMinV1)
24835 MeasmenuA.menu.add_checkbutton(label='Max', variable=MeasMaxV1)
24836 MeasmenuA.menu.add_checkbutton(label='Base', variable=MeasBaseV1)
24837 MeasmenuA.menu.add_checkbutton(label='Top', variable=MeasTopV1)
24838 MeasmenuA.menu.add_checkbutton(label='Mid', variable=MeasMidV1)
24839 MeasmenuA.menu.add_checkbutton(label='P-P', variable=MeasPPV1)
24840 MeasmenuA.menu.add_checkbutton(label='RMS', variable=MeasRMSV1)
24841 MeasmenuA.menu.add_checkbutton(label='CA-CB', variable=MeasDiffAB)
24842 MeasmenuA.menu.add_checkbutton(label='CA-CB RMS', variable=MeasRMSVA_B)
24843 MeasmenuA.menu.add_checkbutton(label='User', variable=MeasUserA, command=BUserAMeas)
24844 #MeasmenuA.menu.add_separator()
24845 MeasmenuA.menu.add_command(label="-CA-I-", foreground="blue", command=donothing)
24846 MeasmenuA.menu.add_checkbutton(label='Avg', variable=MeasDCI1)
24847 MeasmenuA.menu.add_checkbutton(label='Min', variable=MeasMinI1)
24848 MeasmenuA.menu.add_checkbutton(label='Max', variable=MeasMaxI1)
24849 MeasmenuA.menu.add_checkbutton(label='Mid', variable=MeasMidI1)
24850 MeasmenuA.menu.add_checkbutton(label='P-P', variable=MeasPPI1)
24851 MeasmenuA.menu.add_checkbutton(label='RMS', variable=MeasRMSI1)
24852 #MeasmenuA.menu.add_separator()
24853 MeasmenuA.menu.add_command(label="-CA-Time-", foreground="blue", command=donothing)
24854 MeasmenuA.menu.add_checkbutton(label='H-Width', variable=MeasAHW)
24855 MeasmenuA.menu.add_checkbutton(label='L-Width', variable=MeasALW)
24856 MeasmenuA.menu.add_checkbutton(label='DutyCyle', variable=MeasADCy)
24857 MeasmenuA.menu.add_checkbutton(label='Period', variable=MeasAPER)
24858 MeasmenuA.menu.add_checkbutton(label='Freq', variable=MeasAFREQ)
24859 MeasmenuA.menu.add_checkbutton(label='A-B Phase', variable=MeasPhase)
24860 #
24861 MeasmenuA.pack(side=LEFT)
24862 #
24863 MeasmenuB = Menubutton(dropmenu2, text="CB", style="W3.TButton")
24864 MeasmenuB.menu = Menu(MeasmenuB, tearoff = 0 )
24865 MeasmenuB["menu"] = MeasmenuB.menu
24866 MeasmenuB.menu.add_command(label="-CB-V-", foreground="blue", command=donothing)
24867 MeasmenuB.menu.add_checkbutton(label='Avg', variable=MeasDCV2)
24868 MeasmenuB.menu.add_checkbutton(label='Min', variable=MeasMinV2)
24869 MeasmenuB.menu.add_checkbutton(label='Max', variable=MeasMaxV2)
24870 MeasmenuB.menu.add_checkbutton(label='Base', variable=MeasBaseV2)
24871 MeasmenuB.menu.add_checkbutton(label='Top', variable=MeasTopV2)
24872 MeasmenuB.menu.add_checkbutton(label='Mid', variable=MeasMidV2)
24873 MeasmenuB.menu.add_checkbutton(label='P-P', variable=MeasPPV2)
24874 MeasmenuB.menu.add_checkbutton(label='RMS', variable=MeasRMSV2)
24875 MeasmenuB.menu.add_checkbutton(label='CB-CA', variable=MeasDiffBA)
24876 MeasmenuB.menu.add_checkbutton(label='User', variable=MeasUserB, command=BUserBMeas)
24877 #MeasmenuB.menu.add_separator()
24878 MeasmenuB.menu.add_command(label="-CB-I-", foreground="blue", command=donothing)
24879 MeasmenuB.menu.add_checkbutton(label='Avg', variable=MeasDCI2)
24880 MeasmenuB.menu.add_checkbutton(label='Min', variable=MeasMinI2)
24881 MeasmenuB.menu.add_checkbutton(label='Max', variable=MeasMaxI2)
24882 MeasmenuB.menu.add_checkbutton(label='Mid', variable=MeasMidI2)
24883 MeasmenuB.menu.add_checkbutton(label='P-P', variable=MeasPPI2)
24884 MeasmenuB.menu.add_checkbutton(label='RMS', variable=MeasRMSI2)
24885 #MeasmenuB.menu.add_separator()
24886 MeasmenuB.menu.add_command(label="-CB-Time-", foreground="blue", command=donothing)
24887 MeasmenuB.menu.add_checkbutton(label='H-Width', variable=MeasBHW)
24888 MeasmenuB.menu.add_checkbutton(label='L-Width', variable=MeasBLW)
24889 MeasmenuB.menu.add_checkbutton(label='DutyCyle', variable=MeasBDCy)
24890 MeasmenuB.menu.add_checkbutton(label='Period', variable=MeasBPER)
24891 MeasmenuB.menu.add_checkbutton(label='Freq', variable=MeasBFREQ)
24892 MeasmenuB.menu.add_checkbutton(label='B-A Delay', variable=MeasDelay)
24893 MeasmenuB.pack(side=LEFT)
24894 if ShowBallonHelp > 0:
24895  math_tip = CreateToolTip(mathbt, 'Open Math window')
24896  options_tip = CreateToolTip(Optionmenu, 'Select Optional Settings')
24897  file_tip = CreateToolTip(Filemenu, 'Select File operations')
24898 #
24899 DigScreenStatus = IntVar(0)
24900 DigScreenStatus.set(0)
24901 #
24902 if EnableScopeOnly == 0:
24903  BuildAWGScreen = Button(frame2r, text="AWG Window", style="W16.TButton", command=MakeAWGWindow)
24904  BuildAWGScreen.pack(side=TOP)
24905  # Mode selector
24906  timebtn = Frame( frame2r )
24907  timebtn.pack(side=TOP)
24908  ckb1 = Checkbutton(timebtn, text="Enab", style="Disab.TCheckbutton", variable=TimeDisp, command=TimeCheckBox)
24909  ckb1.pack(side=LEFT)
24910  timelab = Label(timebtn, text="Time Plot")
24911  timelab.pack(side=LEFT)
24912  if EnableXYPlotter > 0:
24913  xybtn = Frame( frame2r )
24914  xybtn.pack(side=TOP)
24915  ckb2 = Checkbutton(xybtn, text="Enab", style="Disab.TCheckbutton", variable=XYDisp, command=XYCheckBox)
24916  ckb2.pack(side=LEFT)
24917  BuildXYScreen = Button(xybtn, text="X-Y Plot", style="W11.TButton", command=MakeXYWindow)
24918  BuildXYScreen.pack(side=TOP)
24919  #
24920  if EnablePhaseAnalizer > 0:
24921  phasebtn = Frame( frame2r )
24922  phasebtn.pack(side=TOP)
24923  phckb = Checkbutton(phasebtn, text="Enab", style="Disab.TCheckbutton", variable=PhADisp, command=PhACheckBox)
24924  phckb.pack(side=LEFT)
24925  BuildPhAScreen = Button(phasebtn, text="Phasor Plot", style="W11.TButton", command=MakePhAWindow)
24926  BuildPhAScreen.pack(side=LEFT)
24927  #
24928  if EnableSpectrumAnalizer > 0:
24929  freqbtn = Frame( frame2r )
24930  freqbtn.pack(side=TOP)
24931  ckb3 = Checkbutton(freqbtn, text="Enab", style="Disab.TCheckbutton", variable=FreqDisp, command=FreqCheckBox)
24932  ckb3.pack(side=LEFT)
24933  BuildSpectrumScreen = Button(freqbtn, text="Spectrum Plot", style="W11.TButton", command=MakeSpectrumWindow)
24934  BuildSpectrumScreen.pack(side=LEFT)
24935  #
24936  if EnableBodePlotter > 0:
24937  bodebtn = Frame( frame2r )
24938  bodebtn.pack(side=TOP)
24939  ckb5 = Checkbutton(bodebtn, text="Enab", style="Disab.TCheckbutton", variable=BodeDisp, command=BodeCheckBox)
24940  ckb5.pack(side=LEFT)
24941  BuildBodeScreen = Button(bodebtn, text="Bode Plot", style="W11.TButton", command=MakeBodeWindow)
24942  BuildBodeScreen.pack(side=LEFT)
24943  #
24944  if EnableImpedanceAnalizer > 0:
24945  impdbtn = Frame( frame2r )
24946  impdbtn.pack(side=TOP)
24947  ckb4 = Checkbutton(impdbtn, text="Enab", style="Disab.TCheckbutton", variable=IADisp, command=IACheckBox)
24948  ckb4.pack(side=LEFT)
24949  BuildIAScreen = Button(impdbtn, text="Impedance", style="W11.TButton", command=MakeIAWindow)
24950  BuildIAScreen.pack(side=LEFT)
24951  #
24952  if EnableOhmMeter > 0:
24953  dcohmbtn = Frame( frame2r )
24954  dcohmbtn.pack(side=TOP)
24955  ckb6 = Checkbutton(dcohmbtn, text="Enab", style="Disab.TCheckbutton", variable=OhmDisp, command=OhmCheckBox)
24956  ckb6.pack(side=LEFT)
24957  BuildOhmScreen = Button(dcohmbtn, text="Ohmmeter", style="W11.TButton", command=MakeOhmWindow)
24958  BuildOhmScreen.pack(side=LEFT)
24959  #
24960  if ShowTraceControls > 0:
24961  Labelfonttext = "Arial " + str(FontSize) + " bold"
24962  tracelab = Label(frame2r, text="Traces", font= Labelfonttext)
24963  tracelab.pack(side=TOP)
24964  trctrla = Frame( frame2r )
24965  trctrla.pack(side=TOP)
24966  ckbt1 = Checkbutton(trctrla, text='CA-V (1)', style="Strace1.TCheckbutton", variable=ShowC1_V, command=TraceSelectADC_Mux)
24967  ckbt1.pack(side=LEFT,fill=X)
24968  ckbt2 = Checkbutton(trctrla, text='CA-I (3)', style="Strace3.TCheckbutton", variable=ShowC1_I, command=TraceSelectADC_Mux)
24969  ckbt2.pack(side=LEFT,fill=X)
24970  trctrlb = Frame( frame2r )
24971  trctrlb.pack(side=TOP)
24972  ckbt3 = Checkbutton(trctrlb, text='CB-V (2)', style="Strace2.TCheckbutton", variable=ShowC2_V, command=TraceSelectADC_Mux)
24973  ckbt3.pack(side=LEFT,fill=X)
24974  ckbt4 = Checkbutton(trctrlb, text='CB-I (4)', style="Strace4.TCheckbutton", variable=ShowC2_I, command=TraceSelectADC_Mux)
24975  ckbt4.pack(side=LEFT,fill=X)
24976 
24977  if ShowBallonHelp > 0:
24978  try:
24979  BuildAWGScreen_tip = CreateToolTip(BuildAWGScreen, 'Surface AWG Controls window')
24980  except:
24981  donothing()
24982  try:
24983  BuildXYScreen_tip = CreateToolTip(BuildXYScreen, 'Open X vs Y plot window')
24984  except:
24985  donothing()
24986  try:
24987  BuildPhAScreen_tip = CreateToolTip(BuildPhAScreen, 'Open Phase Analyzer window')
24988  except:
24989  donothing()
24990  try:
24991  BuildSpectrumScreen_tip = CreateToolTip(BuildSpectrumScreen, 'Open Spectrum Analyzer window')
24992  except:
24993  donothing()
24994  try:
24995  BuildBodeScreen_tip = CreateToolTip(BuildBodeScreen, 'Open Bode plot window')
24996  except:
24997  donothing()
24998  try:
24999  BuildIAScreen_tip = CreateToolTip(BuildIAScreen, 'Open Impedance Analyzer window')
25000  except:
25001  donothing()
25002  try:
25003  BuildOhmScreen_tip = CreateToolTip(BuildOhmScreen, 'Open DC Ohmmeter window')
25004  except:
25005  donothing()
25006  # Digital Input / Output Option screens
25007  if EnableDigIO > 0:
25008  BuildDigScreen = Button(frame2r, text="Digital I/O Screen", style="W17.TButton", command=MakeDigScreen)
25009  BuildDigScreen.pack(side=TOP)
25010  # Optional plugin tools
25011  if EnablePIODACMode > 0:
25012  BuildDacScreen = Button(frame2r, text="PIO-DAC Screen", style="W17.TButton", command=MakeDacScreen)
25013  BuildDacScreen.pack(side=TOP)
25014  if EnableMuxMode > 0:
25015  BuildMuxScreen = Button(frame2r, text="Analog In Mux Screen", style="W17.TButton", command=MakeMuxModeWindow)
25016  BuildMuxScreen.pack(side=TOP)
25017  if EnableMinigenMode > 0:
25018  BuildMinigenScreen = Button(frame2r, text="AD983x DDS Screen", style="W17.TButton", command=MakeMinigenWindow)
25019  BuildMinigenScreen.pack(side=TOP)
25020  if EnablePmodDA1Mode > 0:
25021  BuildDA1Screen = Button(frame2r, text="PMOD DA1 Screen", style="W17.TButton", command=MakeDA1Window)
25022  BuildDA1Screen.pack(side=TOP)
25023  if EnableDigPotMode >0:
25024  BuildDigPotScreen = Button(frame2r, text="Dig Pot Screen", style="W17.TButton", command=MakeDigPotWindow)
25025  BuildDigPotScreen.pack(side=TOP)
25026  if EnableGenericSerialMode >0:
25027  GenericSerialScreen = Button(frame2r, text="Generic Serial Output", style="W17.TButton", command=MakeGenericSerialWindow)
25028  GenericSerialScreen.pack(side=TOP)
25029  if EnableAD5626SerialMode >0:
25030  AD5626SerialScreen = Button(frame2r, text="AD5626 Output", style="W17.TButton", command=MakeAD5626Window)
25031  AD5626SerialScreen.pack(side=TOP)
25032  if EnableDigitalFilter >0:
25033  DigFiltScreen = Button(frame2r, text="Digital Filter", style="W17.TButton", command=MakeDigFiltWindow)
25034  DigFiltScreen.pack(side=TOP)
25035  if EnableCommandInterface > 0:
25036  CommandLineScreen = Button(frame2r, text="Command Interface", style="W17.TButton", command=MakeCommandScreen)
25037  CommandLineScreen.pack(side=TOP)
25038  if EnableMeasureScreen > 0:
25039  MeasureScreen = Button(frame2r, text="Measure Screen", style="W17.TButton", command=MakeMeasureScreen)
25040  MeasureScreen.pack(side=TOP)
25041  if EnableETSScreen > 0:
25042  ETSScreen = Button(frame2r, text="ETS Controls", style="W17.TButton", command=MakeETSWindow)
25043  ETSScreen.pack(side=TOP)
25044 else:
25045 # Mode selector
25046  if EnableXYPlotter > 0:
25047  xybtn = Frame( frame2r )
25048  xybtn.pack(side=TOP)
25049  ckb2 = Checkbutton(xybtn, text="Enab", style="Disab.TCheckbutton", variable=XYDisp, command=XYCheckBox)
25050  ckb2.pack(side=LEFT)
25051  BuildXYScreen = Button(xybtn, text="X-Y Plot", style="W11.TButton", command=MakeXYWindow)
25052  BuildXYScreen.pack(side=TOP)
25053  #
25054  if ShowTraceControls > 0:
25055  Labelfonttext = "Arial " + str(FontSize) + " bold"
25056  tracelab = Label(frame2r, text="Traces", font= Labelfonttext)
25057  tracelab.pack(side=TOP)
25058  trctrla = Frame( frame2r )
25059  trctrla.pack(side=TOP)
25060  ckbt1 = Checkbutton(trctrla, text='CA-V (1)', style="Strace1.TCheckbutton", variable=ShowC1_V, command=TraceSelectADC_Mux)
25061  ckbt1.pack(side=LEFT,fill=X)
25062  ckbt2 = Checkbutton(trctrla, text='CA-I (3)', style="Strace3.TCheckbutton", variable=ShowC1_I, command=TraceSelectADC_Mux)
25063  ckbt2.pack(side=LEFT,fill=X)
25064  trctrlb = Frame( frame2r )
25065  trctrlb.pack(side=TOP)
25066  ckbt3 = Checkbutton(trctrlb, text='CB-V (2)', style="Strace2.TCheckbutton", variable=ShowC2_V, command=TraceSelectADC_Mux)
25067  ckbt3.pack(side=LEFT,fill=X)
25068  ckbt4 = Checkbutton(trctrlb, text='CB-I (4)', style="Strace4.TCheckbutton", variable=ShowC2_I, command=TraceSelectADC_Mux)
25069  ckbt4.pack(side=LEFT,fill=X)
25070  #
25071  awg1eb = Frame( frame2r )
25072  awg1eb.pack(side=TOP)
25073  ModeAMenu = Menubutton(awg1eb, text="Mode", width=5, style="Ctrace1.TButton")#, style="W5.TButton")
25074  ModeAMenu.menu = Menu(ModeAMenu, tearoff = 0 )
25075  ModeAMenu["menu"] = ModeAMenu.menu
25076  ModeAMenu.menu.add_command(label="-Mode-", foreground="blue", command=donothing)
25077  ModeAMenu.menu.add_radiobutton(label="SVMI", variable=AWGAMode, value=0, command=BAWGAModeLabel)
25078  ModeAMenu.menu.add_radiobutton(label="SIMV", variable=AWGAMode, value=1, command=BAWGAModeLabel)
25079  ModeAMenu.menu.add_radiobutton(label="Hi-Z", variable=AWGAMode, value=2, command=BAWGAModeLabel)
25080  ModeAMenu.menu.add_checkbutton(label="Split I/O", variable=AWGAIOMode, command=BAWGAModeLabel)
25081  ModeAMenu.menu.add_separator()
25082  ModeAMenu.menu.add_command(label="-Term-", foreground="blue", command=donothing)
25083  ModeAMenu.menu.add_radiobutton(label="Open", variable=AWGATerm, value=0, command=UpdateAwgCont)
25084  ModeAMenu.menu.add_radiobutton(label="To GND", variable=AWGATerm, value=1, command=UpdateAwgCont)
25085  ModeAMenu.menu.add_radiobutton(label="To 2.5V", variable=AWGATerm, value=2, command=UpdateAwgCont)
25086  ModeAMenu.pack(side=LEFT, anchor=W)
25087  ShapeAMenu = Menubutton(awg1eb, text="Shape", width=6, style="Ctrace1.TButton")#, style="W6.TButton")
25088  ShapeAMenu.menu = Menu(ShapeAMenu, tearoff = 0 )
25089  ShapeAMenu["menu"] = ShapeAMenu.menu
25090  ShapeAMenu.menu.add_command(label="-Basic-", foreground="blue", command=donothing)
25091  ShapeAMenu.menu.add_radiobutton(label="DC", variable=AWGAShape, value=0, command=ReMakeAWGwaves)
25092  ShapeAMenu.menu.add_radiobutton(label="Sine", variable=AWGAShape, value=18, command=ReMakeAWGwaves)
25093  ShapeAMenu.menu.add_radiobutton(label="Triangle", variable=AWGAShape, value=2, command=ReMakeAWGwaves)
25094  ShapeAMenu.menu.add_radiobutton(label="Sawtooth", variable=AWGAShape, value=3, command=ReMakeAWGwaves)
25095  ShapeAMenu.menu.add_radiobutton(label="Square", variable=AWGAShape, value=4, command=ReMakeAWGwaves)
25096  ShapeAMenu.menu.add_radiobutton(label="StairStep", variable=AWGAShape, value=5, command=ReMakeAWGwaves)
25097  if AWGShowAdvanced.get() > 0:
25098  ShapeAMenu.menu.add_command(label="-Advanced-", foreground="blue", command=donothing)
25099  ShapeAMenu.menu.add_radiobutton(label="Impulse", variable=AWGAShape, value=9, command=ReMakeAWGwaves)
25100  ShapeAMenu.menu.add_radiobutton(label="Trapezoid", variable=AWGAShape, value=11, command=ReMakeAWGwaves)
25101  ShapeAMenu.menu.add_radiobutton(label="Pulse", variable=AWGAShape, value=20, command=ReMakeAWGwaves)
25102  ShapeAMenu.menu.add_radiobutton(label="Ramp", variable=AWGAShape, value=16, command=ReMakeAWGwaves)
25103  ShapeAMenu.menu.add_radiobutton(label="SSQ Pulse", variable=AWGAShape, value=15, command=ReMakeAWGwaves)
25104  ShapeAMenu.menu.add_radiobutton(label="U-D Ramp", variable=AWGAShape, value=12, command=ReMakeAWGwaves)
25105  ShapeAMenu.menu.add_radiobutton(label="Fourier Series", variable=AWGAShape, value=14, command=AWGAMakeFourier)
25106  ShapeAMenu.menu.add_radiobutton(label="Sin X/X", variable=AWGAShape, value=19, command=ReMakeAWGwaves)
25107  ShapeAMenu.menu.add_radiobutton(label="PWM Sine", variable=AWGAShape, value=17, command=ReMakeAWGwaves)
25108  ShapeAMenu.menu.add_radiobutton(label="FM Sine", variable=AWGAShape, value=21, command=AWGAMakeFMSine)
25109  ShapeAMenu.menu.add_radiobutton(label="AM Sine", variable=AWGAShape, value=22, command=AWGAMakeAMSine)
25110  ShapeAMenu.menu.add_radiobutton(label="UU Noise", variable=AWGAShape, value=7, command=ReMakeAWGwaves)
25111  ShapeAMenu.menu.add_radiobutton(label="UG Noise", variable=AWGAShape, value=8, command=ReMakeAWGwaves)
25112  else:
25113  ShapeAMenu.menu.add_separator()
25114  ShapeAMenu.menu.add_radiobutton(label="Math", variable=AWGAShape, value=10, command=AWGAMakeMath)
25115  ShapeAMenu.menu.add_radiobutton(label="Read CSV File", variable=AWGAShape, value=6, command=AWGAReadFile)
25116  ShapeAMenu.menu.add_radiobutton(label="Read WAV File", variable=AWGAShape, value=13, command=AWGAReadWAV)
25117  ShapeAMenu.menu.add_command(label="Save CSV File", command=AWGAWriteFile)
25118  ShapeAMenu.menu.add_checkbutton(label='Burst', variable=AWGABurstFlag, command=AWGANumCycles)
25119  ShapeAMenu.menu.add_checkbutton(label='Repeat', variable=AWGARepeatFlag)
25120  ShapeAMenu.pack(side=LEFT, anchor=W)
25121  #
25122  awg1model = Frame( frame2r )
25123  awg1model.pack(side=TOP,fill=X) #)
25124  AWGAModeLabel = Label(awg1model, text="AWG A Mode", background=COLORtrace1, font=('Arial', FontSize, 'bold'))
25125  AWGAModeLabel.pack(side=LEFT, fill=X)
25126  AWGAShapeLabel = Label(awg1model, text="AWG A Shape", background=COLORtrace1, font=('Arial', FontSize, 'bold'))
25127  AWGAShapeLabel.pack(side=LEFT, fill=X)
25128  #
25129  awg1ampl = Frame( frame2r )
25130  awg1ampl.pack(side=TOP,fill=X) #)
25131  amp1lab = Label(awg1ampl) #
25132  amp1lab.grid(row=0,column=0,sticky=E+S+N+W)
25133  off1lab = Label(awg1ampl) #
25134  off1lab.grid(row=0,column=1,sticky=E+S+N+W)
25135  freq1lab = Label(awg1ampl, text="Freq")
25136  freq1lab.grid(row=0,column=2,sticky=E+S+N+W)
25137  #
25138  AWGAAmplEntry = Entry(awg1ampl, width=5, cursor='double_arrow')
25139  AWGAAmplEntry.bind("<Return>", UpdateAwgContRet)
25140  AWGAAmplEntry.bind('<MouseWheel>', onAWGAscroll)
25141  AWGAAmplEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
25142  AWGAAmplEntry.bind("<Button-5>", onAWGAscroll)
25143  AWGAAmplEntry.bind('<Key>', onTextKeyAWG)
25144  AWGAAmplEntry.grid(row=1,column=0,sticky=E+S+N+W)
25145  AWGAAmplEntry.delete(0,"end")
25146  AWGAAmplEntry.insert(0,0.0)
25147  #
25148  AWGAOffsetEntry = Entry(awg1ampl, width=5, cursor='double_arrow')
25149  AWGAOffsetEntry.bind("<Return>", UpdateAwgContRet)
25150  AWGAOffsetEntry.bind('<MouseWheel>', onAWGAscroll)
25151  AWGAOffsetEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
25152  AWGAOffsetEntry.bind("<Button-5>", onAWGAscroll)
25153  AWGAOffsetEntry.bind('<Key>', onTextKeyAWG)
25154  AWGAOffsetEntry.grid(row=1,column=1,sticky=E+S+N+W)
25155  AWGAOffsetEntry.delete(0,"end")
25156  AWGAOffsetEntry.insert(0,0.0)
25157 
25158  if AWG_Amp_Mode.get() == 0:
25159  amp1lab.config(text = "Min" ) # change displayed value
25160  off1lab.config(text = "Max" ) # change displayed value
25161  else:
25162  amp1lab.config(text = "Amp" )
25163  off1lab.config(text = "Off" )
25164  # AWG Frequency sub frame
25165  AWGAFreqEntry = Entry(awg1ampl, width=7, cursor='double_arrow')
25166  AWGAFreqEntry.bind("<Return>", UpdateAwgContRet)
25167  AWGAFreqEntry.bind('<MouseWheel>', onAWGAscroll)
25168  AWGAFreqEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
25169  AWGAFreqEntry.bind("<Button-5>", onAWGAscroll)
25170  AWGAFreqEntry.bind('<Key>', onTextKeyAWG)
25171  AWGAFreqEntry.grid(row=1,column=2,sticky=E+S+N+W)
25172  AWGAFreqEntry.delete(0,"end")
25173  AWGAFreqEntry.insert(0,100.0)
25174  # AWG Phase or delay select sub frame
25175  # AWG Phase entry sub frame
25176  awg1phase = Frame( frame2r )
25177  awg1phase.pack(side=TOP)
25178  awgaph = Button(awg1phase, text="Phase", style="W5.TButton", command=ToggleAWGAPhaseDelay)
25179  awgaph.pack(side=LEFT, anchor=W)
25180  AWGAPhaseEntry = Entry(awg1phase, width=4, cursor='double_arrow')
25181  AWGAPhaseEntry.bind("<Return>", UpdateAwgContRet)
25182  AWGAPhaseEntry.bind('<MouseWheel>', onAWGAscroll)
25183  AWGAPhaseEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
25184  AWGAPhaseEntry.bind("<Button-5>", onAWGAscroll)
25185  AWGAPhaseEntry.bind('<Key>', onTextKeyAWG)
25186  AWGAPhaseEntry.pack(side=LEFT, anchor=W)
25187  AWGAPhaseEntry.delete(0,"end")
25188  AWGAPhaseEntry.insert(0,0)
25189  phasealab = Label(awg1phase, text="Deg")
25190  phasealab.pack(side=LEFT, anchor=W)
25191  # AWG duty cycle frame
25192  awg1dc = Frame( frame2r )
25193  awg1dc.pack(side=TOP)
25194  AWGADutyCycleEntry = Entry(awg1dc, width=5, cursor='double_arrow')
25195  AWGADutyCycleEntry.bind("<Return>", UpdateAwgContRet)
25196  AWGADutyCycleEntry.bind('<MouseWheel>', onAWGAscroll)
25197  AWGADutyCycleEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
25198  AWGADutyCycleEntry.bind("<Button-5>", onAWGAscroll)
25199  AWGADutyCycleEntry.bind('<Key>', onTextKeyAWG)
25200  AWGADutyCycleEntry.pack(side=LEFT, anchor=W)
25201  AWGADutyCycleEntry.delete(0,"end")
25202  AWGADutyCycleEntry.insert(0,50)
25203  duty1lab = Label(awg1dc, text="%")
25204  duty1lab.pack(side=LEFT, anchor=W)
25205 
25218  awg2eb = Frame( frame2r )
25219  awg2eb.pack(side=TOP)
25220  ModeBMenu = Menubutton(awg2eb, text="Mode", width=5, style="Ctrace2.TButton")# , style="W5.TButton")
25221  ModeBMenu.menu = Menu(ModeBMenu, tearoff = 0 )
25222  ModeBMenu["menu"] = ModeBMenu.menu
25223  ModeBMenu.menu.add_command(label="-Mode-", foreground="blue", command=donothing)
25224  ModeBMenu.menu.add_radiobutton(label="SVMI", variable=AWGBMode, value=0, command=BAWGBModeLabel)
25225  ModeBMenu.menu.add_radiobutton(label="SIMV", variable=AWGBMode, value=1, command=BAWGBModeLabel)
25226  ModeBMenu.menu.add_radiobutton(label="Hi-Z", variable=AWGBMode, value=2, command=BAWGBModeLabel)
25227  ModeBMenu.menu.add_checkbutton(label="Split I/O", variable=AWGBIOMode, command=BAWGBModeLabel)
25228  ModeBMenu.menu.add_separator()
25229  ModeBMenu.menu.add_command(label="-Term-", foreground="blue", command=donothing)
25230  ModeBMenu.menu.add_radiobutton(label="Open", variable=AWGBTerm, value=0, command=UpdateAwgCont)
25231  ModeBMenu.menu.add_radiobutton(label="To GND", variable=AWGBTerm, value=1, command=UpdateAwgCont)
25232  ModeBMenu.menu.add_radiobutton(label="To 2.5V", variable=AWGBTerm, value=2, command=UpdateAwgCont)
25233  ModeBMenu.pack(side=LEFT, anchor=W)
25234  ShapeBMenu = Menubutton(awg2eb, text="Shape", width=6, style="Ctrace2.TButton")#, style="W6.TButton")
25235  ShapeBMenu.menu = Menu(ShapeBMenu, tearoff = 0 )
25236  ShapeBMenu["menu"] = ShapeBMenu.menu
25237  ShapeBMenu.menu.add_command(label="-Basic-", foreground="blue", command=donothing)
25238  ShapeBMenu.menu.add_radiobutton(label="DC", variable=AWGBShape, value=0, command=ReMakeAWGwaves)
25239  ShapeBMenu.menu.add_radiobutton(label="Sine", variable=AWGBShape, value=18, command=ReMakeAWGwaves)
25240  ShapeBMenu.menu.add_radiobutton(label="Triangle", variable=AWGBShape, value=2, command=ReMakeAWGwaves)
25241  ShapeBMenu.menu.add_radiobutton(label="Sawtooth", variable=AWGBShape, value=3, command=ReMakeAWGwaves)
25242  ShapeBMenu.menu.add_radiobutton(label="Square", variable=AWGBShape, value=4, command=ReMakeAWGwaves)
25243  ShapeBMenu.menu.add_radiobutton(label="StairStep", variable=AWGBShape, value=5, command=ReMakeAWGwaves)
25244  if AWGShowAdvanced.get() > 0:
25245  ShapeBMenu.menu.add_command(label="-Advanced-", foreground="blue", command=donothing)
25246  ShapeBMenu.menu.add_radiobutton(label="Impulse", variable=AWGBShape, value=9, command=ReMakeAWGwaves)
25247  ShapeBMenu.menu.add_radiobutton(label="Trapezoid", variable=AWGBShape, value=11, command=ReMakeAWGwaves)
25248  ShapeBMenu.menu.add_radiobutton(label="Pulse", variable=AWGBShape, value=20, command=ReMakeAWGwaves)
25249  ShapeBMenu.menu.add_radiobutton(label="Ramp", variable=AWGBShape, value=16, command=ReMakeAWGwaves)
25250  ShapeBMenu.menu.add_radiobutton(label="SSQ Pulse", variable=AWGBShape, value=15, command=ReMakeAWGwaves)
25251  ShapeBMenu.menu.add_radiobutton(label="U-D Ramp", variable=AWGBShape, value=12, command=ReMakeAWGwaves)
25252  ShapeBMenu.menu.add_radiobutton(label="Fourier Series", variable=AWGBShape, value=14, command=AWGBMakeFourier)
25253  ShapeBMenu.menu.add_radiobutton(label="Sin X/X", variable=AWGBShape, value=19, command=ReMakeAWGwaves)
25254  ShapeBMenu.menu.add_radiobutton(label="PWM Sine", variable=AWGBShape, value=17, command=ReMakeAWGwaves)
25255  ShapeBMenu.menu.add_radiobutton(label="UU Noise", variable=AWGBShape, value=7, command=ReMakeAWGwaves)
25256  ShapeBMenu.menu.add_radiobutton(label="UG Noise", variable=AWGBShape, value=8, command=ReMakeAWGwaves)
25257  else:
25258  ShapeBMenu.menu.add_separator()
25259  ShapeBMenu.menu.add_radiobutton(label="Math", variable=AWGBShape, value=10, command=AWGBMakeMath)
25260  ShapeBMenu.menu.add_radiobutton(label="Read CSV File", variable=AWGBShape, value=6, command=AWGBReadFile)
25261  ShapeBMenu.menu.add_radiobutton(label="Read WAV File", variable=AWGBShape, value=13, command=AWGBReadWAV)
25262  ShapeBMenu.menu.add_command(label="Save CSV File", command=AWGBWriteFile)
25263  ShapeBMenu.menu.add_checkbutton(label='Burst', variable=AWGBBurstFlag, command=AWGBNumCycles)
25264  ShapeBMenu.menu.add_checkbutton(label='Repeat', variable=AWGBRepeatFlag)
25265  ShapeBMenu.pack(side=LEFT, anchor=W)
25266  #
25267  awg2model = Frame( frame2r )
25268  awg2model.pack(side=TOP,fill=X) #)
25269  AWGBModeLabel = Label(awg2model, text="AWG B Mode", background=COLORtrace2, font=('Arial', FontSize, 'bold'))
25270  AWGBModeLabel.pack(side=LEFT, fill=X)
25271  AWGBShapeLabel = Label(awg2model, text="AWG B Shape", background=COLORtrace2, font=('Arial', FontSize, 'bold'))
25272  AWGBShapeLabel.pack(side=LEFT, fill=X)
25273  #
25274  awg2ampl = Frame( frame2r )
25275  awg2ampl.pack(side=TOP)
25276  amp2lab = Label(awg2ampl) #, text="Min Ch B")
25277  amp2lab.grid(row=0,column=0,sticky=E+S+N+W)
25278  #amp2lab.pack(side=LEFT, anchor=W)
25279  off2lab = Label(awg2ampl) #, text="Max Ch B")
25280  off2lab.grid(row=0,column=1,sticky=E+S+N+W)
25281  #off2lab.pack(side=LEFT, anchor=W)
25282  freq2lab = Label(awg2ampl, text="Freq")
25283  freq2lab.grid(row=0,column=2,sticky=E+S+N+W)
25284  # freq2lab.pack(side=LEFT, anchor=W)
25285  #
25286  AWGBAmplEntry = Entry(awg2ampl, width=5, cursor='double_arrow')
25287  AWGBAmplEntry.bind("<Return>", UpdateAwgContRet)
25288  AWGBAmplEntry.bind('<MouseWheel>', onAWGBscroll)
25289  AWGBAmplEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
25290  AWGBAmplEntry.bind("<Button-5>", onAWGBscroll)
25291  AWGBAmplEntry.bind('<Key>', onTextKeyAWG)
25292  AWGBAmplEntry.grid(row=1,column=0,sticky=E+S+N+W)
25293  AWGBAmplEntry.delete(0,"end")
25294  AWGBAmplEntry.insert(0,0.0)
25295  #
25296  AWGBOffsetEntry = Entry(awg2ampl, width=5, cursor='double_arrow')
25297  AWGBOffsetEntry.bind("<Return>", UpdateAwgContRet)
25298  AWGBOffsetEntry.bind('<MouseWheel>', onAWGBscroll)
25299  AWGBOffsetEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
25300  AWGBOffsetEntry.bind("<Button-5>", onAWGBscroll)
25301  AWGBOffsetEntry.bind('<Key>', onTextKeyAWG)
25302  AWGBOffsetEntry.grid(row=1,column=1,sticky=E+S+N+W)
25303  AWGBOffsetEntry.delete(0,"end")
25304  AWGBOffsetEntry.insert(0,0.0)
25305 
25306  if AWG_Amp_Mode.get() == 0:
25307  amp2lab.config(text = "Min" ) # change displayed value
25308  off2lab.config(text = "Max" ) # change displayed value
25309  else:
25310  amp2lab.config(text = "Amp" )
25311  off2lab.config(text = "Off" )
25312  # AWG Frequency
25313  AWGBFreqEntry = Entry(awg2ampl, width=7, cursor='double_arrow')
25314  AWGBFreqEntry.bind("<Return>", UpdateAwgContRet)
25315  AWGBFreqEntry.bind('<MouseWheel>', onAWGBscroll)
25316  AWGBFreqEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
25317  AWGBFreqEntry.bind("<Button-5>", onAWGBscroll)
25318  AWGBFreqEntry.bind('<Key>', onTextKeyAWG)
25319  AWGBFreqEntry.grid(row=1,column=2,sticky=E+S+N+W)
25320  AWGBFreqEntry.delete(0,"end")
25321  AWGBFreqEntry.insert(0,100.0)
25322  # AWG Phase or delay select sub frame
25323  # AWG Phase sub frame
25324  awg2phase = Frame( frame2r )
25325  awg2phase.pack(side=TOP)
25326  awgbph = Button(awg2phase, text="Phase", style="W5.TButton", command=ToggleAWGBPhaseDelay)
25327  awgbph.pack(side=LEFT, anchor=W)
25328  AWGBPhaseEntry = Entry(awg2phase, width=5, cursor='double_arrow')
25329  AWGBPhaseEntry.bind("<Return>", UpdateAwgContRet)
25330  AWGBPhaseEntry.bind('<MouseWheel>', onAWGBscroll)
25331  AWGBPhaseEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
25332  AWGBPhaseEntry.bind("<Button-5>", onAWGBscroll)
25333  AWGBPhaseEntry.bind('<Key>', onTextKeyAWG)
25334  AWGBPhaseEntry.pack(side=LEFT, anchor=W)
25335  AWGBPhaseEntry.delete(0,"end")
25336  AWGBPhaseEntry.insert(0,0)
25337  phaseblab = Label(awg2phase, text="Deg")
25338  phaseblab.pack(side=LEFT, anchor=W)
25339  # AWG duty cycle frame
25340  awg2dc = Frame( frame2r )
25341  awg2dc.pack(side=TOP)
25342  AWGBDutyCycleEntry = Entry(awg2dc, width=5, cursor='double_arrow')
25343  AWGBDutyCycleEntry.bind("<Return>", UpdateAwgContRet)
25344  AWGBDutyCycleEntry.bind('<MouseWheel>', onAWGBscroll)
25345  AWGBDutyCycleEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
25346  AWGBDutyCycleEntry.bind("<Button-5>", onAWGBscroll)
25347  AWGBDutyCycleEntry.bind('<Key>', onTextKeyAWG)
25348  AWGBDutyCycleEntry.pack(side=LEFT, anchor=W)
25349  AWGBDutyCycleEntry.delete(0,"end")
25350  AWGBDutyCycleEntry.insert(0,50)
25351  duty2lab = Label(awg2dc, text="%")
25352  duty2lab.pack(side=LEFT, anchor=W)
25353  #
25354  bcompa = Checkbutton(frame2r, text="B = Comp A", variable=BisCompA, command=ReMakeAWGwaves)
25355  bcompa.pack(side=TOP)
25356 
25357  awgsync = Checkbutton(frame2r, text="Sync AWG", variable=AWGSync, command=BAWGSync)
25358  awgsync.pack(side=TOP)
25359  if ShowBallonHelp > 0:
25360  BuildAWGAPhase_tip = CreateToolTip(awgaph, 'Toggle between degrees and time')
25361  BuildAWGBPhase_tip = CreateToolTip(awgbph, 'Toggle between degrees and time')
25362  BuildAWGSync_tip = CreateToolTip(awgsync, 'Toggle between continuous and discontinuous modes')
25363  BuildBComp_tip = CreateToolTip(bcompa, 'Lock CH B to be the inverse of CH A')
25364  BuildModeAMenu_tip = CreateToolTip(ModeAMenu, 'Configure channel output mode')
25365  BuildModeBMenu_tip = CreateToolTip(ModeBMenu, 'Configure channel output mode')
25366  BuildShapeAMenu_tip = CreateToolTip(ShapeAMenu, 'Set channel waveform shape')
25367  BuildShapeBMenu_tip = CreateToolTip(ShapeBMenu, 'Set channel waveform shape')
25368 
25369 # input probe wigets
25370 prlab = Label(frame2r, text="Adjust Gain / Offset")
25371 prlab.pack(side=TOP)
25372 # Input Probes sub frame
25373 ProbeA = Frame( frame2r )
25374 ProbeA.pack(side=TOP)
25375 gain1lab = Button(ProbeA, text="CA-V", width=4, style="Ctrace1.TButton", command=ReSetAGO)
25376 gain1lab.pack(side=LEFT,fill=X)
25377 CHAVGainEntry = Entry(ProbeA, width=5, cursor='double_arrow')
25378 CHAVGainEntry.bind('<Return>', onTextKey)
25379 CHAVGainEntry.bind('<MouseWheel>', onTextScroll)
25380 CHAVGainEntry.bind("<Button-4>", onTextScroll)# with Linux OS
25381 CHAVGainEntry.bind("<Button-5>", onTextScroll)
25382 CHAVGainEntry.bind('<Key>', onTextKey)
25383 CHAVGainEntry.pack(side=LEFT)
25384 CHAVGainEntry.delete(0,"end")
25385 CHAVGainEntry.insert(0,1.0)
25386 CHAVOffsetEntry = Entry(ProbeA, width=5, cursor='double_arrow')
25387 CHAVOffsetEntry.bind('<Return>', onTextKey)
25388 CHAVOffsetEntry.bind('<MouseWheel>', onTextScroll)
25389 CHAVOffsetEntry.bind("<Button-4>", onTextScroll)# with Linux OS
25390 CHAVOffsetEntry.bind("<Button-5>", onTextScroll)
25391 CHAVOffsetEntry.bind('<Key>', onTextKey)
25392 CHAVOffsetEntry.pack(side=LEFT)
25393 CHAVOffsetEntry.delete(0,"end")
25394 CHAVOffsetEntry.insert(0,0.0)
25395 #
25396 ProbeB = Frame( frame2r )
25397 ProbeB.pack(side=TOP)
25398 gain2lab = Button(ProbeB, text="CB-V", width=4, style="Ctrace2.TButton", command=ReSetBGO)
25399 gain2lab.pack(side=LEFT,fill=X)
25400 CHBVGainEntry = Entry(ProbeB, width=5, cursor='double_arrow')
25401 CHBVGainEntry.bind('<Return>', onTextKey)
25402 CHBVGainEntry.bind('<MouseWheel>', onTextScroll)
25403 CHBVGainEntry.bind("<Button-4>", onTextScroll)# with Linux OS
25404 CHBVGainEntry.bind("<Button-5>", onTextScroll)
25405 CHBVGainEntry.bind('<Key>', onTextKey)
25406 CHBVGainEntry.pack(side=LEFT)
25407 CHBVGainEntry.delete(0,"end")
25408 CHBVGainEntry.insert(0,1.0)
25409 CHBVOffsetEntry = Entry(ProbeB, width=5, cursor='double_arrow')
25410 CHBVOffsetEntry.bind('<Return>', onTextKey)
25411 CHBVOffsetEntry.bind('<MouseWheel>', onTextScroll)
25412 CHBVOffsetEntry.bind("<Button-4>", onTextScroll)# with Linux OS
25413 CHBVOffsetEntry.bind("<Button-5>", onTextScroll)
25414 CHBVOffsetEntry.bind('<Key>', onTextKey)
25415 CHBVOffsetEntry.pack(side=LEFT)
25416 CHBVOffsetEntry.delete(0,"end")
25417 CHBVOffsetEntry.insert(0,0.0)
25418 #
25419 ProbeAI = Frame( frame2r )
25420 ProbeAI.pack(side=TOP)
25421 gainailab = Button(ProbeAI, text="CA-I", width=4, style="Ctrace3.TButton", command=ReSetAIGO)
25422 gainailab.pack(side=LEFT,fill=X)
25423 CHAIGainEntry = Entry(ProbeAI, width=5, cursor='double_arrow')
25424 CHAIGainEntry.bind('<Return>', onTextKey)
25425 CHAIGainEntry.bind('<MouseWheel>', onTextScroll)
25426 CHAIGainEntry.bind("<Button-4>", onTextScroll)# with Linux OS
25427 CHAIGainEntry.bind("<Button-5>", onTextScroll)
25428 CHAIGainEntry.bind('<Key>', onTextKey)
25429 CHAIGainEntry.pack(side=LEFT)
25430 CHAIGainEntry.delete(0,"end")
25431 CHAIGainEntry.insert(0,1.0)
25432 CHAIOffsetEntry = Entry(ProbeAI, width=5, cursor='double_arrow')
25433 CHAIOffsetEntry.bind('<Return>', onTextKey)
25434 CHAIOffsetEntry.bind('<MouseWheel>', onTextScroll)
25435 CHAIOffsetEntry.bind("<Button-4>", onTextScroll)# with Linux OS
25436 CHAIOffsetEntry.bind("<Button-5>", onTextScroll)
25437 CHAIOffsetEntry.bind('<Key>', onTextKey)
25438 CHAIOffsetEntry.pack(side=LEFT)
25439 CHAIOffsetEntry.delete(0,"end")
25440 CHAIOffsetEntry.insert(0,0.0)
25441 #
25442 ProbeBI = Frame( frame2r )
25443 ProbeBI.pack(side=TOP)
25444 gainbilab = Button(ProbeBI, text="CB-I", width=4, style="Ctrace4.TButton", command=ReSetBIGO)
25445 gainbilab.pack(side=LEFT,fill=X)
25446 CHBIGainEntry = Entry(ProbeBI, width=5, cursor='double_arrow')
25447 CHBIGainEntry.bind('<Return>', onTextKey)
25448 CHBIGainEntry.bind('<MouseWheel>', onTextScroll)
25449 CHBIGainEntry.bind("<Button-4>", onTextScroll)# with Linux OS
25450 CHBIGainEntry.bind("<Button-5>", onTextScroll)
25451 CHBIGainEntry.bind('<Key>', onTextKey)
25452 CHBIGainEntry.pack(side=LEFT)
25453 CHBIGainEntry.delete(0,"end")
25454 CHBIGainEntry.insert(0,1.0)
25455 CHBIOffsetEntry = Entry(ProbeBI, width=5, cursor='double_arrow')
25456 CHBIOffsetEntry.bind('<Return>', onTextKey)
25457 CHBIOffsetEntry.bind('<MouseWheel>', onTextScroll)
25458 CHBIOffsetEntry.bind("<Button-4>", onTextScroll)# with Linux OS
25459 CHBIOffsetEntry.bind("<Button-5>", onTextScroll)
25460 CHBIOffsetEntry.bind('<Key>', onTextKey)
25461 CHBIOffsetEntry.pack(side=LEFT)
25462 CHBIOffsetEntry.delete(0,"end")
25463 CHBIOffsetEntry.insert(0,0.0)
25464 # Add a pair of user entry wigets
25465 if EnableUserEntries > 0:
25466  UserEnt = Frame( frame2r )
25467  UserEnt.pack(side=TOP)
25468  userentlab = Button(UserEnt, text="User", width=4, style="W4.TButton")
25469  userentlab.pack(side=LEFT,fill=X)
25470  User1Entry = Entry(UserEnt, width=5, cursor='double_arrow')
25471  User1Entry.bind('<Return>', onTextKey)
25472  User1Entry.bind('<MouseWheel>', onTextScroll)
25473  User1Entry.bind("<Button-4>", onTextScroll)# with Linux OS
25474  User1Entry.bind("<Button-5>", onTextScroll)
25475  User1Entry.bind('<Key>', onTextKey)
25476  User1Entry.pack(side=LEFT)
25477  User1Entry.delete(0,"end")
25478  User1Entry.insert(0,0.0)
25479  User2Entry = Entry(UserEnt, width=5, cursor='double_arrow')
25480  User2Entry.bind('<Return>', onTextKey)
25481  User2Entry.bind('<MouseWheel>', onTextScroll)
25482  User2Entry.bind("<Button-4>", onTextScroll)# with Linux OS
25483  User2Entry.bind("<Button-5>", onTextScroll)
25484  User2Entry.bind('<Key>', onTextKey)
25485  User2Entry.pack(side=LEFT)
25486  User2Entry.delete(0,"end")
25487  User2Entry.insert(0,0.0)
25488 # add ADI logo Don't mess with this bit map data!
25489 ADIlogo = """
25490 R0lGODlhdAAxAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A/wD/
25491 /////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
25492 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMwAAZgAAmQAAzAAA/wAzAAAzMwAzZgAzmQAzzAAz/wBm
25493 AABmMwBmZgBmmQBmzABm/wCZAACZMwCZZgCZmQCZzACZ/wDMAADMMwDMZgDMmQDMzADM/wD/AAD/
25494 MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMzADMzMzMzZjMzmTMzzDMz/zNmADNmMzNm
25495 ZjNmmTNmzDNm/zOZADOZMzOZZjOZmTOZzDOZ/zPMADPMMzPMZjPMmTPMzDPM/zP/ADP/MzP/ZjP/
25496 mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YzAGYzM2YzZmYzmWYzzGYz/2ZmAGZmM2ZmZmZmmWZm
25497 zGZm/2aZAGaZM2aZZmaZmWaZzGaZ/2bMAGbMM2bMZmbMmWbMzGbM/2b/AGb/M2b/Zmb/mWb/zGb/
25498 /5kAAJkAM5kAZpkAmZkAzJkA/5kzAJkzM5kzZpkzmZkzzJkz/5lmAJlmM5lmZplmmZlmzJlm/5mZ
25499 AJmZM5mZZpmZmZmZzJmZ/5nMAJnMM5nMZpnMmZnMzJnM/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwA
25500 M8wAZswAmcwAzMwA/8wzAMwzM8wzZswzmcwzzMwz/8xmAMxmM8xmZsxmmcxmzMxm/8yZAMyZM8yZ
25501 ZsyZmcyZzMyZ/8zMAMzMM8zMZszMmczMzMzM/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8A
25502 mf8AzP8A//8zAP8zM/8zZv8zmf8zzP8z//9mAP9mM/9mZv9mmf9mzP9m//+ZAP+ZM/+ZZv+Zmf+Z
25503 zP+Z///MAP/MM//MZv/Mmf/MzP/M////AP//M///Zv//mf//zP///yH5BAEAABAALAAAAAB0ADEA
25504 AAj/AP8JHEiwoMGDCBMqXMiwocOHEBlSS5WKIUWJfqj9S+XnokGPEUOKdEito0WNCC9OpEbtz7+V
25505 HyuOnEnzI6yMEylWpNgx50aOGkt6LElUoB9VPFHyTAXrYipVNaOSTOWzEEuqA61SXTnxH06ZK7EK
25506 5Ap2J9WdKKWqRVjyJ1c/1ZbqvPnyrKqS215mzEiwo8yfer22XUs4Zse9V31mPFuxbdKxjAU65Si5
25507 8Vm+hTNXrvuWKFKdjs8WJEqR5V63bkP/1bx28E+rK28ihckRayHQnH/yVdUTMtB/1fywHj7TI0iR
25508 x4krd7g0bcjSy6NLn069uvXr2LNr3/6Sip/vU777//EOXjx5P+G/nw/vnCA18gXFOy+JWfL31V6/
25509 s001ZQqK8AdN1B8KJiVETX9TMIGggv0xmOCCEDbYX3sDoTdhXwi6199qFjJRUIMB3iEhgs7x56CC
25510 wrH134r+tcjiiy7G+B+FL7nIYYsp1ojCX9SwuFqLBh343xQc+bGiUjhyhCNbLTbR4oBTODlkk09S
25511 iQKNBz7Z139OotQjkQPxx2WO/3D5kZNUDDSRk8IJOUVabqoo45ww1tkijejt+N9fUM64kX9/GQne
25512 lQMBWdCRGs6Yyp4FFYllhIVM6aCkCFL65kGAHshEjhZa2NiGAlWzJzUK8pngaAmSKVAh/fHWX0Rf
25513 sv+oSnB01iprkIwOWKF//wzIEqBG8drrf4USS9CiYBYEy39/GCrQHzpZFWCVhOoFpZSVRkktheg1
25514 MRaoXhGLbEaM9tpEinmiNGSj4CaaipNTqKltuaPBOF+ftt6JKgpUnGUoFcIaGR6wX371X4rOjnXw
25515 R3tSYexLL+L37YgUmhjhgxSjijHGGln4rYMVoXdihr2eqiETdxhEooUUtuuevQEiayeL7eU5p3B5
25516 ZmXjsHRWlLBAWgA7ULME/rPsqxjuOC2X/tE4VrfUztuef6oCKXDSRBb8MoBc6gSalD1BDVW4E5rW
25517 osQQx+i0mgLbOd/CSWeJwtY7pvvhjLWmDWOOJc3/jHaWHDckd4TOsawxePEeuyGJ7O44opbWDukH
25518 LB8hOGFtAcI4dkNEx7g5d+6xtBBLa8s7ZbUk/XF66aBLFau+D/GntntbwdQo6bXnHmTu83FFO+6k
25519 wxm8QoAzyDrbI186UPIF/vk4in6UStA2DKaC4q4OKp98qsFmnPnsC21jM8zF3izZzB1RTRDRfrBa
25520 dMl1alSrcPgOmVeQVpYuYNRSOtf/RFDbSaaCJzop9cVJFOkPzs6mF3iVjEheo0qzmvAHpcCtXuA7
25521 iJjy5ZyE2Wwi9IpPub4ULzFlhIFP25P6DCKwzQlJVRML3EEstDFLOYdBH7qcyxQ3hUJIJkE7ORip
25522 /5CmptJcEENMQNv3bkW7mc3pcz8bl8xilKN1ka0i7HMfDMsHo42wqIdiWVqlSmSlbGHLVwTRleII
25523 tMFrccpPVnxXeGSnxH+csUk/tFJ96Aa7kuTLbWl82PnmKLn06OeHOxKTTExowoTgCD3i6UvbVqix
25524 wMlue5i80PKIuKoN0VEhCJLd2KzHnushxJSjuySFXnewP3IwkIkrH0WYpRCBkewfWnSTc1TRyvfF
25525 RwuqEtgqy3gt/hkTdXYUVl0cqEiFyE5ozlugL+GXpS32pwkdjNIqncjNWnXwYBZaEVSm+CIyQekv
25526 jYTffaDkpjqpzpOym6a8HmepKk2KcAS5J+OcV0JDAIXJioPMEZQaxJd6Kkqfe1RTNxfquWNRBFo6
25527 oV0qbvNQ6BQxjP/4TOGSpBSKUDQVEH2awHrTupKa9KQoTWl0AgIAOw==
25528 """
25529 logo = PhotoImage(data=ADIlogo)
25530 ADI1 = Label(frame2r, image=logo, anchor= "sw", compound="top") # , height=49, width=116
25531 ADI1.pack(side=TOP)
25532 
25533 # Bottom Buttons
25534 # Voltage channel A
25535 if ButtonOrder == 1:
25536  CHAlab = Button(frame3, text="CA V/Div", style="Rtrace1.TButton", command=SetScaleA)
25537  CHAlab.pack(side=LEFT)
25538 CHAsb = Spinbox(frame3, cursor='double_arrow', width=4, values=CHvpdiv, command=BCHAlevel)
25539 #CHAsb = ttk.Spinbox(frame3, cursor='double_arrow', style="Div.TSpinbox", values=CHvpdiv, command=BCHAlevel)
25540 CHAsb.bind('<MouseWheel>', onSpinBoxScroll)
25541 CHAsb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
25542 CHAsb.bind("<Button-5>", onSpinBoxScroll)
25543 CHAsb.pack(side=LEFT)
25544 CHAsb.delete(0,"end")
25545 CHAsb.insert(0,0.5)
25546 #
25547 if ButtonOrder == 0:
25548  CHAlab = Button(frame3, text="CA V/Div", style="Rtrace1.TButton", command=SetScaleA)
25549  CHAlab.pack(side=LEFT)
25550 #
25551 if ButtonOrder == 1:
25552  CHAofflab = Button(frame3, text="CA V Pos", style="Rtrace1.TButton", command=SetVAPoss)
25553  CHAofflab.pack(side=LEFT)
25554 CHAVPosEntry = Entry(frame3, width=5, cursor='double_arrow')
25555 CHAVPosEntry.bind("<Return>", BOffsetA)
25556 CHAVPosEntry.bind('<MouseWheel>', onTextScroll)# with Windows OS
25557 CHAVPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
25558 CHAVPosEntry.bind("<Button-5>", onTextScroll)
25559 CHAVPosEntry.bind('<Key>', onTextKey)
25560 CHAVPosEntry.pack(side=LEFT)
25561 CHAVPosEntry.delete(0,"end")
25562 CHAVPosEntry.insert(0,2.5)
25563 if ButtonOrder == 0:
25564  CHAofflab = Button(frame3, text="CA V Pos", style="Rtrace1.TButton", command=SetVAPoss)
25565  CHAofflab.pack(side=LEFT)
25566 # Current channel A
25567 if ButtonOrder == 1:
25568  CHAIlab = Button(frame3, text="CA mA/Div", style="Strace3.TButton", command=SetScaleIA)
25569  CHAIlab.pack(side=LEFT)
25570 CHAIsb = Spinbox(frame3, cursor='double_arrow', width=4, values=CHipdiv, command=BCHAIlevel)
25571 CHAIsb.bind('<MouseWheel>', onSpinBoxScroll)
25572 CHAIsb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
25573 CHAIsb.bind("<Button-5>", onSpinBoxScroll)
25574 CHAIsb.pack(side=LEFT)
25575 CHAIsb.delete(0,"end")
25576 CHAIsb.insert(0,50.0)
25577 if ButtonOrder == 0:
25578  CHAIlab = Button(frame3, text="CA mA/Div", style="Strace3.TButton", command=SetScaleIA)
25579  CHAIlab.pack(side=LEFT)
25580 #
25581 if ButtonOrder == 1:
25582  CHAIofflab = Button(frame3, text="CA I Pos", style="Rtrace3.TButton", command=SetIAPoss)
25583  CHAIofflab.pack(side=LEFT)
25584 CHAIPosEntry = Entry(frame3, width=5, cursor='double_arrow')
25585 CHAIPosEntry.bind("<Return>", BIOffsetA)
25586 CHAIPosEntry.bind('<MouseWheel>', onTextScroll)# with Windows OS
25587 CHAIPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
25588 CHAIPosEntry.bind("<Button-5>", onTextScroll)
25589 CHAIPosEntry.bind('<Key>', onTextKey)
25590 CHAIPosEntry.pack(side=LEFT)
25591 CHAIPosEntry.delete(0,"end")
25592 CHAIPosEntry.insert(0,0.0)
25593 if ButtonOrder == 0:
25594  CHAIofflab = Button(frame3, text="CA I Pos", style="Rtrace3.TButton", command=SetIAPoss)
25595  CHAIofflab.pack(side=LEFT)
25596 # Voltage channel B
25597 if ButtonOrder == 1:
25598  CHBlab = Button(frame3, text="CB V/Div", style="Strace2.TButton", command=SetScaleB)
25599  CHBlab.pack(side=LEFT)
25600 CHBsb = Spinbox(frame3, width=4, cursor='double_arrow', values=CHvpdiv, command=BCHBlevel)
25601 CHBsb.bind('<MouseWheel>', onSpinBoxScroll)
25602 CHAIsb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
25603 CHAIsb.bind("<Button-5>", onSpinBoxScroll)
25604 CHBsb.pack(side=LEFT)
25605 CHBsb.delete(0,"end")
25606 CHBsb.insert(0,0.5)
25607 #
25608 if ButtonOrder == 0:
25609  CHBlab = Button(frame3, text="CB V/Div", style="Strace2.TButton", command=SetScaleB)
25610  CHBlab.pack(side=LEFT)
25611 #
25612 if ButtonOrder == 1:
25613  CHBofflab = Button(frame3, text="CB V Pos", style="Rtrace2.TButton", command=SetVBPoss)
25614  CHBofflab.pack(side=LEFT)
25615 CHBVPosEntry = Entry(frame3, width=5, cursor='double_arrow')
25616 CHBVPosEntry.bind("<Return>", BOffsetB)
25617 CHBVPosEntry.bind('<MouseWheel>', onTextScroll)# with Windows OS
25618 CHBVPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
25619 CHBVPosEntry.bind("<Button-5>", onTextScroll)
25620 CHBVPosEntry.bind('<Key>', onTextKey)
25621 CHBVPosEntry.pack(side=LEFT)
25622 CHBVPosEntry.delete(0,"end")
25623 CHBVPosEntry.insert(0,2.5)
25624 if ButtonOrder == 0:
25625  CHBofflab = Button(frame3, text="CB V Pos", style="Rtrace2.TButton", command=SetVBPoss)
25626  CHBofflab.pack(side=LEFT)
25627 # Current channel B
25628 if ButtonOrder == 1:
25629  CHBIlab = Button(frame3, text="CB mA/Div", style="Strace4.TButton", command=SetScaleIB)
25630  CHBIlab.pack(side=LEFT)
25631 CHBIsb = Spinbox(frame3, width=4, cursor='double_arrow', values=CHipdiv, command=BCHBIlevel)
25632 CHBIsb.bind('<MouseWheel>', onSpinBoxScroll)
25633 CHBIsb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
25634 CHBIsb.bind("<Button-5>", onSpinBoxScroll)
25635 CHBIsb.pack(side=LEFT)
25636 CHBIsb.delete(0,"end")
25637 CHBIsb.insert(0,50.0)
25638 if ButtonOrder == 0:
25639  CHBIlab = Button(frame3, text="CB mA/Div", style="Strace4.TButton", command=SetScaleIB)
25640  CHBIlab.pack(side=LEFT)
25641 #
25642 if ButtonOrder == 1:
25643  CHBIofflab = Button(frame3, text="CB I Pos", style="Rtrace4.TButton", command=SetIBPoss)
25644  CHBIofflab.pack(side=LEFT)
25645 CHBIPosEntry = Entry(frame3, width=5, cursor='double_arrow')
25646 CHBIPosEntry.bind("<Return>", BIOffsetB)
25647 CHBIPosEntry.bind('<MouseWheel>', onTextScroll)# with Windows OS
25648 CHBIPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
25649 CHBIPosEntry.bind("<Button-5>", onTextScroll)
25650 CHBIPosEntry.bind('<Key>', onTextKey)
25651 CHBIPosEntry.pack(side=LEFT)
25652 CHBIPosEntry.delete(0,"end")
25653 CHBIPosEntry.insert(0,0.0)
25654 if ButtonOrder == 0:
25655  CHBIofflab = Button(frame3, text="CB I Pos", style="Rtrace4.TButton", command=SetIBPoss)
25656  CHBIofflab.pack(side=LEFT)
25657 #
25658 if ShowBallonHelp > 0:
25659  CHAlab_tip = CreateToolTip(CHAlab, 'Select CHA-V vertical range/position axis to be used for markers and drawn color')
25660  CHBlab_tip = CreateToolTip(CHBlab, 'Select CHB-V vertical range/position axis to be used for markers and drawn color')
25661  CHAIlab_tip = CreateToolTip(CHAIlab, 'Select CHA-I vertical range/position axis to be used for markers and drawn color')
25662  CHBIlab_tip = CreateToolTip(CHBIlab, 'Select CHB-I vertical range/position axis to be used for markers and drawn color')
25663  CHAofflab_tip = CreateToolTip(CHAofflab, 'Set CHA-V position to DC average of signal')
25664  CHBofflab_tip = CreateToolTip(CHBofflab, 'Set CHB-V position to DC average of signal')
25665  CHAIofflab_tip = CreateToolTip(CHAIofflab, 'Set CHA-I position to DC average of signal')
25666  CHBIofflab_tip = CreateToolTip(CHBIofflab, 'Set CHB-I position to DC average of signal')
25667  gain1lab_tip = CreateToolTip(gain1lab, 'Reset Gain to 1.0 and Offset to 0.0')
25668  gain2lab_tip = CreateToolTip(gain2lab, 'Reset Gain to 1.0 and Offset to 0.0')
25669  gainailab_tip = CreateToolTip(gainailab, 'Reset Gain to 1.0 and Offset to 0.0')
25670  gainbilab_tip = CreateToolTip(gainbilab, 'Reset Gain to 1.0 and Offset to 0.0')
25671 #
25672 root.geometry('+300+0')
25673 root.protocol("WM_DELETE_WINDOW", Bcloseexit)
25674 #===== Initalize device ======
25675 if not numpy_found:
25676  root.update()
25677  showwarning("WARNING","Numpy not found!")
25678  root.destroy()
25679  exit()
25680 #
25681 BrdSel = IntVar(0)
25682 BoardStatus = IntVar(0)
25683 if pysmu_found:
25684  ConnectDevice()
25685  #session.hotplug_attach(ConnectDevice)
25686  #session.hotplug_detach(ConnectDevice)
25687  if EnableScopeOnly == 0:
25688  MakeAWGWindow() # build AWG window
25689  else:
25690  AWGScreenStatus.set(1)
25691  # root.update()
25692  BLoadConfig("alice-last-config.cfg") # load configuration from last session
25693  if LocalLanguage != "English":
25694  BLoadConfig(LocalLanguage) # load local language configuration
25695 # ================ Call main routine ===============================
25696  root.update() # Activate updated screens
25697 # Start sampling
25698  Analog_In()
25699 else:
25700  root.update()
25701  showwarning("WARNING","Pysmu not found!")
25702  root.destroy()
25703  exit()
25704 
alice-desktop-1.IApBtoggle
def IApBtoggle()
Definition: alice-desktop-1.3.pyw:16627
alice-desktop-1.Analog_Chop_Time
def Analog_Chop_Time()
Definition: alice-desktop-1.3-linux-test.pyw:4121
alice-desktop-1.DestroySpectrumScreen
def DestroySpectrumScreen()
Definition: alice-desktop-1.3-linux-test.pyw:19733
alice-desktop-1.ApplyMathString
def ApplyMathString()
Apply Math string from entry widget.
Definition: alice-desktop-1.3-linux-test.pyw:2697
alice-desktop-1.DoNothing
def DoNothing(event)
Another Nop.
Definition: alice-desktop-1.3-linux-test.pyw:2731
alice-desktop-1.CheckMathString
def CheckMathString()
Check Math String for syntac errors.
Definition: alice-desktop-1.3-linux-test.pyw:2637
alice-desktop-1.DestroyPhAScreen
def DestroyPhAScreen()
Definition: alice-desktop-1.3-linux-test.pyw:16112
alice-desktop-1.SetDualMuxMode
def SetDualMuxMode()
Definition: alice-desktop-1.3-linux-test.pyw:18940
alice-desktop-1.SetColorT2
def SetColorT2()
Definition: alice-desktop-1.3.pyw:2229
alice-desktop-1.UpdatePhAScreen
def UpdatePhAScreen()
Definition: alice-desktop-1.3-linux-test.pyw:16139
alice-desktop-1.MakeMuxModeWindow
def MakeMuxModeWindow()
Definition: alice-desktop-1.3-linux-test.pyw:18744
alice-desktop-1.DestroyBoardScreen
def DestroyBoardScreen()
Definition: alice-desktop-1.3-linux-test.pyw:22081
alice-desktop-1.BLoadConfigTime
def BLoadConfigTime()
Load confirfuration from Scope window button.
Definition: alice-desktop-1.3-linux-test.pyw:1913
alice-desktop-1.BTriglevel
def BTriglevel(event)
evalute trigger level entry string to a numerical value and set new trigger level
Definition: alice-desktop-1.3-linux-test.pyw:2813
alice-desktop-1.DestroyCommandScreen
def DestroyCommandScreen()
Definition: alice-desktop-1.3-linux-test.pyw:21837
alice-desktop-1.onSrateScroll
def onSrateScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:22275
alice-desktop-1.BSweepSync
def BSweepSync()
Definition: alice-desktop-1.3-linux-test.pyw:19042
alice-desktop-1.IASourceSet
def IASourceSet()
Set up IA AWG sources.
Definition: alice-desktop-1.3-linux-test.pyw:3125
alice-desktop-1.Bsamples2
def Bsamples2()
Definition: alice-desktop-1.3-linux-test.pyw:13191
alice-desktop-1.onCanvasFive
def onCanvasFive(event)
Definition: alice-desktop-1.3-linux-test.pyw:9669
alice-desktop-1.UpdateTimeScreen
def UpdateTimeScreen()
Update time screen with trace and text.
Definition: alice-desktop-1.3-linux-test.pyw:6002
alice-desktop-1.BSaveConfigIA
def BSaveConfigIA()
Save current configuration from IA window.
Definition: alice-desktop-1.3-linux-test.pyw:1557
alice-desktop-1.onAWGFiltBScroll
def onAWGFiltBScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:21656
alice-desktop-1.MakeFreqScreen
def MakeFreqScreen()
Make Spectrum Analyzer Screen.
Definition: alice-desktop-1.3-linux-test.pyw:17168
alice-desktop-1.BStartIA
def BStartIA()
Start Impedance Tool
Definition: alice-desktop-1.3-linux-test.pyw:3105
alice-desktop-1.SelectBoard
def SelectBoard()
temp = 0 print "read ADM1177 controler" print devx.ctrl_transfer( 0xa0, 0x17, 0, 0,...
Definition: alice-desktop-1.3-linux-test.pyw:22117
alice-desktop-1.RunScript
def RunScript()
Run a script file.
Definition: alice-desktop-1.3-linux-test.pyw:1920
alice-desktop-1.sel
def sel()
Definition: alice-desktop-1.3-linux-test.pyw:5648
alice-desktop-1.UpdateAWGA
def UpdateAWGA()
Definition: alice-desktop-1.3-linux-test.pyw:11359
alice-desktop-1.Analog_Roll_time
def Analog_Roll_time()
Definition: alice-desktop-1.3-linux-test.pyw:3986
alice-desktop-1.onMiniGenScroll
def onMiniGenScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:20773
alice-desktop-1.IncHoldOff
def IncHoldOff()
Definition: alice-desktop-1.3-linux-test.pyw:2867
alice-desktop-1.SetColorTR4
def SetColorTR4()
Definition: alice-desktop-1.3.pyw:2346
alice-desktop-1.UpdateIAScreen
def UpdateIAScreen()
Definition: alice-desktop-1.3-linux-test.pyw:14738
alice-desktop-1.AWGBMakeMath
def AWGBMakeMath()
Definition: alice-desktop-1.3-linux-test.pyw:11882
alice-desktop-1.UpdateAwgContRet
def UpdateAwgContRet(temp)
Definition: alice-desktop-1.3-linux-test.pyw:12766
alice-desktop-1.ToggleAWGBPhaseDelay
def ToggleAWGBPhaseDelay()
Definition: alice-desktop-1.3-linux-test.pyw:11682
alice-desktop-1.AWGBMakeFullWaveSine
def AWGBMakeFullWaveSine()
Definition: alice-desktop-1.3.pyw:12579
alice-desktop-1.UpdateAWGWin
def UpdateAWGWin()
Definition: alice-desktop-1.3-linux-test.pyw:23134
alice-desktop-1.onRetSrate
def onRetSrate(event)
Definition: alice-desktop-1.3-linux-test.pyw:22281
alice-desktop-1.AWGBMakePWMSine
def AWGBMakePWMSine()
Definition: alice-desktop-1.3-linux-test.pyw:12020
alice-desktop-1.MakeXYTrace
def MakeXYTrace()
Make the XY plot traces.
Definition: alice-desktop-1.3-linux-test.pyw:7101
alice-desktop-1.onCanvasSeven
def onCanvasSeven(event)
Definition: alice-desktop-1.3-linux-test.pyw:9679
alice-desktop-1.ApplyMathYString
def ApplyMathYString()
Apply Y Math string from entry widget.
Definition: alice-desktop-1.3-linux-test.pyw:2711
alice-desktop-1.DoImpedance
def DoImpedance()
Definition: alice-desktop-1.3-linux-test.pyw:14742
alice-desktop-1.BExecuteFromString
def BExecuteFromString()
Definition: alice-desktop-1.3-linux-test.pyw:21847
alice-desktop-1.STOREcsvfile
def STOREcsvfile()
Definition: alice-desktop-1.3-linux-test.pyw:17084
alice-desktop-1.AWGBMakeRamp
def AWGBMakeRamp()
Definition: alice-desktop-1.3-linux-test.pyw:12310
alice-desktop-1.AWGBReadFile
def AWGBReadFile()
Definition: alice-desktop-1.3-linux-test.pyw:11775
alice-desktop-1.DestroyETSScreen
def DestroyETSScreen()
Definition: alice-desktop-1.3-linux-test.pyw:22688
alice-desktop-1.onCanvasShowTcur
def onCanvasShowTcur(event)
Definition: alice-desktop-1.3-linux-test.pyw:9721
alice-desktop-1.SetIBPoss
def SetIBPoss()
Definition: alice-desktop-1.3-linux-test.pyw:2975
alice-desktop-1.Sine_Phase
def Sine_Phase()
Definition: alice-desktop-1.3-linux-test.pyw:4937
alice-desktop-1.UpdateIAAll
def UpdateIAAll()
Definition: alice-desktop-1.3-linux-test.pyw:14724
alice-desktop-1.ETSscroll
def ETSscroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:22706
alice-desktop-1.AWGAMakeUUNoise
def AWGAMakeUUNoise()
Definition: alice-desktop-1.3-linux-test.pyw:11246
alice-desktop-1.SetColorTR2
def SetColorTR2()
Definition: alice-desktop-1.3.pyw:2324
alice-desktop-1.BOffsetB
def BOffsetB(event)
Definition: alice-desktop-1.3-linux-test.pyw:3300
alice-desktop-1.MakeIATrace
def MakeIATrace()
Definition: alice-desktop-1.3-linux-test.pyw:14786
alice-desktop-1.BDBdiv1
def BDBdiv1()
Definition: alice-desktop-1.3-linux-test.pyw:13212
alice-desktop-1.ColorSelector
def ColorSelector()
Color Selector / Editor.
Definition: alice-desktop-1.3.pyw:2088
alice-desktop-1.BStopSA
def BStopSA()
Definition: alice-desktop-1.3-linux-test.pyw:13107
alice-desktop-1.onCanvasAverage
def onCanvasAverage(event)
Definition: alice-desktop-1.3-linux-test.pyw:9713
alice-desktop-1.Analog_Fast_time
def Analog_Fast_time()
Definition: alice-desktop-1.3-linux-test.pyw:4192
alice-desktop-1.BNormalmode
def BNormalmode()
Definition: alice-desktop-1.3-linux-test.pyw:12847
alice-desktop-1.BIOffsetB
def BIOffsetB(event)
Definition: alice-desktop-1.3-linux-test.pyw:3312
alice-desktop-1.BLoadDFiltB
def BLoadDFiltB()
Definition: alice-desktop-1.3-linux-test.pyw:21589
alice-desktop-1.BFileFFTwindow
def BFileFFTwindow()
Definition: alice-desktop-1.3-linux-test.pyw:17749
alice-desktop-1.NewEnterMathControls
def NewEnterMathControls()
Make New Math waveform controls menu window.
Definition: alice-desktop-1.3-linux-test.pyw:2475
alice-desktop-1.DestroyXYScreen
def DestroyXYScreen()
Definition: alice-desktop-1.3-linux-test.pyw:20032
alice-desktop-1.UpdateNiCAll
def UpdateNiCAll()
Definition: alice-desktop-1.3-linux-test.pyw:15866
alice-desktop-1.UpdateNqPAll
def UpdateNqPAll()
Definition: alice-desktop-1.3-linux-test.pyw:15847
alice-desktop-1.BSTOREtraceBP
def BSTOREtraceBP()
Definition: alice-desktop-1.3-linux-test.pyw:12918
alice-desktop-1.BTriggerEdge
def BTriggerEdge()
Function no longer used.
Definition: alice-desktop-1.3-linux-test.pyw:2754
alice-desktop-1.SetXYScaleA
def SetXYScaleA()
Definition: alice-desktop-1.3-linux-test.pyw:9090
alice-desktop-1.onMulXScroll
def onMulXScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:22716
alice-desktop-1.BCHAlevel
def BCHAlevel()
Definition: alice-desktop-1.3-linux-test.pyw:3232
alice-desktop-1.AWGAMakeFMSine
def AWGAMakeFMSine()
Definition: alice-desktop-1.3-linux-test.pyw:10579
alice-desktop-1.VBtoggle
def VBtoggle()
Definition: alice-desktop-1.3-linux-test.pyw:15902
alice-desktop-1.BSaveScreenBP
def BSaveScreenBP()
Save Bode canvas as encapsulated postscript file.
Definition: alice-desktop-1.3-linux-test.pyw:2088
alice-desktop-1.AddAWGANoise
def AddAWGANoise()
Definition: alice-desktop-1.3-linux-test.pyw:11492
alice-desktop-1.MakeIAWindow
def MakeIAWindow()
Definition: alice-desktop-1.3-linux-test.pyw:15330
alice-desktop-1.onCanvasXYLeftClick
def onCanvasXYLeftClick(event)
Definition: alice-desktop-1.3-linux-test.pyw:9768
alice-desktop-1.UpdateFreqAll
def UpdateFreqAll()
Definition: alice-desktop-1.3-linux-test.pyw:13447
alice-desktop-1.onCanvasShowBdBcur
def onCanvasShowBdBcur(event)
Definition: alice-desktop-1.3-linux-test.pyw:18195
alice-desktop-1.RExecuteFromString
def RExecuteFromString(temp)
Definition: alice-desktop-1.3-linux-test.pyw:21843
alice-desktop-1.AWGALoadCSV
def AWGALoadCSV()
Definition: alice-desktop-1.3-linux-test.pyw:10354
alice-desktop-1.onCanvasFreqLeftClick
def onCanvasFreqLeftClick(event)
Definition: alice-desktop-1.3-linux-test.pyw:17803
alice-desktop-1.SetXYVAPoss
def SetXYVAPoss()
Definition: alice-desktop-1.3-linux-test.pyw:2981
alice-desktop-1.AddAWGBNoise
def AddAWGBNoise()
Definition: alice-desktop-1.3-linux-test.pyw:12729
alice-desktop-1.BSaveConfigBP
def BSaveConfigBP()
Save current configuration from Bode window.
Definition: alice-desktop-1.3-linux-test.pyw:1569
alice-desktop-1.DestroyNqPScreen
def DestroyNqPScreen()
Definition: alice-desktop-1.3-linux-test.pyw:15578
alice-desktop-1.UpdatePotSlider
def UpdatePotSlider()
Definition: alice-desktop-1.3-linux-test.pyw:20995
alice-desktop-1.onCanvasBodeLeftClick
def onCanvasBodeLeftClick(event)
Definition: alice-desktop-1.3-linux-test.pyw:18043
alice-desktop-1.BAWGAModeLabel
def BAWGAModeLabel()
Definition: alice-desktop-1.3-linux-test.pyw:11336
alice-desktop-1.BrownNoise
def BrownNoise(N, mag)
Definition: alice-desktop-1.3-linux-test.pyw:10031
alice-desktop-1.MakePhAScreen
def MakePhAScreen()
Definition: alice-desktop-1.3-linux-test.pyw:16345
alice-desktop-1.BLoadDFiltAClip
def BLoadDFiltAClip()
Definition: alice-desktop-1.3-linux-test.pyw:2203
alice-desktop-1.BSnapShotXY
def BSnapShotXY()
Take snap shot of displayed XY Traces.
Definition: alice-desktop-1.3-linux-test.pyw:2318
alice-desktop-1.AWGBMakeSSQ
def AWGBMakeSSQ()
Definition: alice-desktop-1.3-linux-test.pyw:12116
alice-desktop-1.DestroyIAScreen
def DestroyIAScreen()
Definition: alice-desktop-1.3-linux-test.pyw:15526
alice-desktop-1.BReadFromClipboard
def BReadFromClipboard()
Definition: alice-desktop-1.3-linux-test.pyw:2193
alice-desktop-1.BAWG2X
def BAWG2X()
Definition: alice-desktop-1.3-linux-test.pyw:18715
alice-desktop-1.onCanvasMouse_xy
def onCanvasMouse_xy(event)
Definition: alice-desktop-1.3-linux-test.pyw:23331
alice-desktop-1.MakeFreqTrace
def MakeFreqTrace()
Definition: alice-desktop-1.3-linux-test.pyw:13800
alice-desktop-1.onAWGBkey
def onAWGBkey(event)
Definition: alice-desktop-1.3-linux-test.pyw:18264
alice-desktop-1.AWGAMakeSSQ
def AWGAMakeSSQ()
Definition: alice-desktop-1.3-linux-test.pyw:10862
alice-desktop-1.onCanvasShowPcur
def onCanvasShowPcur(event)
Definition: alice-desktop-1.3-linux-test.pyw:18004
alice-desktop-1.AWGAReadWAV
def AWGAReadWAV()
Definition: alice-desktop-1.3-linux-test.pyw:10428
alice-desktop-1.onCanvasThree
def onCanvasThree(event)
Definition: alice-desktop-1.3-linux-test.pyw:9653
alice-desktop-1.DestroyOOTwindow
def DestroyOOTwindow()
Definition: alice-desktop-1.3-linux-test.pyw:23500
alice-desktop-1.UpdateNqPScreen
def UpdateNqPScreen()
Definition: alice-desktop-1.3-linux-test.pyw:15861
alice-desktop-1.AWGAMakePulse
def AWGAMakePulse()
Definition: alice-desktop-1.3-linux-test.pyw:10988
alice-desktop-1.MakeAD5626Window
def MakeAD5626Window()
Make Controls for AD5626 serial DAC.
Definition: alice-desktop-1.3-linux-test.pyw:21143
alice-desktop-1.onCanvasSAZero
def onCanvasSAZero(event)
Definition: alice-desktop-1.3-linux-test.pyw:17971
alice-desktop-1.AWGAMakeSinc
def AWGAMakeSinc()
Definition: alice-desktop-1.3-linux-test.pyw:10804
alice-desktop-1.DestroyOhmScreen
def DestroyOhmScreen()
Definition: alice-desktop-1.3-linux-test.pyw:22581
alice-desktop-1.SetColorTR5
def SetColorTR5()
Definition: alice-desktop-1.3.pyw:2357
alice-desktop-1.BDSweepFromFile
def BDSweepFromFile()
Definition: alice-desktop-1.3-linux-test.pyw:19052
alice-desktop-1.onCanvasXYScrollClick
def onCanvasXYScrollClick(event)
Definition: alice-desktop-1.3-linux-test.pyw:9746
alice-desktop-1.AWGBMakePulse
def AWGBMakePulse()
Definition: alice-desktop-1.3-linux-test.pyw:12240
alice-desktop-1.SetTriggerPoss
def SetTriggerPoss()
Definition: alice-desktop-1.3-linux-test.pyw:2849
alice-desktop-1.SetColorT5
def SetColorT5()
Definition: alice-desktop-1.3.pyw:2274
alice-desktop-1.ApplyMathXString
def ApplyMathXString()
Apply X Math string from entry widget.
Definition: alice-desktop-1.3-linux-test.pyw:2704
alice-desktop-1.SetScaleMuxB
def SetScaleMuxB()
Definition: alice-desktop-1.3-linux-test.pyw:2921
alice-desktop-1.AWGANumCycles
def AWGANumCycles()
Definition: alice-desktop-1.3-linux-test.pyw:10414
alice-desktop-1.onCanvasSAPeak
def onCanvasSAPeak(event)
Definition: alice-desktop-1.3-linux-test.pyw:17981
alice-desktop-1.onCanvasRightArrow
def onCanvasRightArrow(event)
Move Time curcors right 1 or 5.
Definition: alice-desktop-1.3-linux-test.pyw:9284
alice-desktop-1.onRetAWGFiltB
def onRetAWGFiltB(event)
Definition: alice-desktop-1.3-linux-test.pyw:21653
alice-desktop-1.ToggleAWGAPhaseDelay
def ToggleAWGAPhaseDelay()
Definition: alice-desktop-1.3-linux-test.pyw:10256
alice-desktop-1.onCanvasShowBPcur
def onCanvasShowBPcur(event)
Definition: alice-desktop-1.3-linux-test.pyw:18188
alice-desktop-1.CreateToolTip.tw
tw
Definition: alice-desktop-1.3-linux-test.pyw:893
alice-desktop-1.BAWGFiltBMath
def BAWGFiltBMath()
Definition: alice-desktop-1.3-linux-test.pyw:21744
alice-desktop-1.onCanvasSAThree
def onCanvasSAThree(event)
Definition: alice-desktop-1.3-linux-test.pyw:17928
alice-desktop-1.MakeNiCScreen
def MakeNiCScreen()
Make the Nichols Plot screen.
Definition: alice-desktop-1.3-linux-test.pyw:15722
alice-desktop-1.DestroyDigPotScreen
def DestroyDigPotScreen()
Definition: alice-desktop-1.3-linux-test.pyw:21063
alice-desktop-1.ReInterploateTrigger
def ReInterploateTrigger(TrgBuff)
Interpolate time between samples around trigger event.
Definition: alice-desktop-1.3-linux-test.pyw:5512
alice-desktop-1.onCanvasZero
def onCanvasZero(event)
Definition: alice-desktop-1.3-linux-test.pyw:9694
alice-desktop-1.BShowCurvesNoneSA
def BShowCurvesNoneSA()
Definition: alice-desktop-1.3-linux-test.pyw:12840
alice-desktop-1.BAWGAPhase
def BAWGAPhase(temp)
Definition: alice-desktop-1.3-linux-test.pyw:10278
alice-desktop-1.BAWGBPhaseDelay
def BAWGBPhaseDelay()
Definition: alice-desktop-1.3-linux-test.pyw:11694
alice-desktop-1.UpdateTimeTrace
def UpdateTimeTrace()
Update time trace and screen.
Definition: alice-desktop-1.3-linux-test.pyw:5997
alice-desktop-1.SetColorT7
def SetColorT7()
Definition: alice-desktop-1.3.pyw:2299
alice-desktop-1.AWGALoadWAV
def AWGALoadWAV()
Definition: alice-desktop-1.3-linux-test.pyw:10437
alice-desktop-1.BSaveData
def BSaveData()
Save scope all time array data to file.
Definition: alice-desktop-1.3-linux-test.pyw:2105
alice-desktop-1.XYCheckBox
def XYCheckBox()
Definition: alice-desktop-1.3-linux-test.pyw:3331
alice-desktop-1.Bcloseexit
def Bcloseexit()
Fubntion to close and exit ALICE.
Definition: alice-desktop-1.3-linux-test.pyw:3005
alice-desktop-1.DestroyMathScreen
def DestroyMathScreen()
Destroy New Math waveform controls menu window.
Definition: alice-desktop-1.3-linux-test.pyw:2630
alice-desktop-1.BIOffsetA
def BIOffsetA(event)
Definition: alice-desktop-1.3-linux-test.pyw:3288
alice-desktop-1.SetADC_Mux
def SetADC_Mux()
Definition: alice-desktop-1.3-linux-test.pyw:22362
alice-desktop-1.BLoadConfig
def BLoadConfig(filename)
Load configuration from a file
Definition: alice-desktop-1.3-linux-test.pyw:1580
alice-desktop-1.onCanvasBdZero
def onCanvasBdZero(event)
Definition: alice-desktop-1.3-linux-test.pyw:18181
alice-desktop-1.BSaveConfigTime
def BSaveConfigTime()
Save current configuration from Scope window.
Definition: alice-desktop-1.3-linux-test.pyw:1575
alice-desktop-1.UpdatePhATrace
def UpdatePhATrace()
Definition: alice-desktop-1.3-linux-test.pyw:16135
alice-desktop-1.BLoadAWGFiltA
def BLoadAWGFiltA()
Definition: alice-desktop-1.3-linux-test.pyw:21679
alice-desktop-1.BuildBoxCarA
def BuildBoxCarA()
Definition: alice-desktop-1.3-linux-test.pyw:21502
alice-desktop-1.SetColorTR1
def SetColorTR1()
Definition: alice-desktop-1.3.pyw:2313
alice-desktop-1.onCanvasTwo
def onCanvasTwo(event)
Definition: alice-desktop-1.3-linux-test.pyw:9645
alice-desktop-1.BHelp
def BHelp()
Open User Guide in Browser open a URL, in this case, the ALICE desk-top-users-guide.
Definition: alice-desktop-1.3-linux-test.pyw:2262
alice-desktop-1.SetVBPoss
def SetVBPoss()
Definition: alice-desktop-1.3-linux-test.pyw:2963
font
alice-desktop-1.AWGBMakeUUNoise
def AWGBMakeUUNoise()
Definition: alice-desktop-1.3-linux-test.pyw:12494
alice-desktop-1.ReMakeAWGwaves
def ReMakeAWGwaves()
Re Make the current selected AWG waveform buffers.
Definition: alice-desktop-1.3-linux-test.pyw:1768
alice-desktop-1.AWGBMakeImpulse
def AWGBMakeImpulse()
Definition: alice-desktop-1.3-linux-test.pyw:12439
alice-desktop-1.SetETSComp
def SetETSComp()
Definition: alice-desktop-1.3-linux-test.pyw:23100
alice-desktop-1.IAtoggle
def IAtoggle()
Definition: alice-desktop-1.3-linux-test.pyw:15910
alice-desktop-1.MakeETSWindow
def MakeETSWindow()
Definition: alice-desktop-1.3-linux-test.pyw:22589
alice-desktop-1.SetScaleB
def SetScaleB()
Definition: alice-desktop-1.3-linux-test.pyw:9066
alice-desktop-1.AWGBReadWAV
def AWGBReadWAV()
Definition: alice-desktop-1.3-linux-test.pyw:11841
alice-desktop-1.INITIALIZEstart
def INITIALIZEstart()
Definition: alice-desktop-1.3-linux-test.pyw:17636
alice-desktop-1.BAWGBDutyCycle
def BAWGBDutyCycle(temp)
Definition: alice-desktop-1.3-linux-test.pyw:11722
alice-desktop-1.BAWGAOffset
def BAWGAOffset(temp)
Definition: alice-desktop-1.3-linux-test.pyw:10183
alice-desktop-1.Digital_RC_Low_Pass
def Digital_RC_Low_Pass(InBuff, TC1, Gain)
Digital filter function for input divider frequency compensation TC1 is in micro seconds.
Definition: alice-desktop-1.3-linux-test.pyw:4980
alice-desktop-1.time_points_from_freq
def time_points_from_freq(freq, fs=1, density=False)
Definition: alice-desktop-1.3-linux-test.pyw:9949
alice-desktop-1.Digital_RC_High_Pass
def Digital_RC_High_Pass(InBuff, TC1, Gain)
Digital RC filter function for input divider frequency compensation TC1 is in micro seconds.
Definition: alice-desktop-1.3-linux-test.pyw:4959
alice-desktop-1.UpdateMeasureScreen
def UpdateMeasureScreen()
Definition: alice-desktop-1.3-linux-test.pyw:21926
alice-desktop-1.onCanvasClickRight
def onCanvasClickRight(event)
Definition: alice-desktop-1.3-linux-test.pyw:9104
alice-desktop-1.onCanvasSANine
def onCanvasSANine(event)
Definition: alice-desktop-1.3-linux-test.pyw:17967
alice-desktop-1.BLoadDFiltBClip
def BLoadDFiltBClip()
Definition: alice-desktop-1.3-linux-test.pyw:2209
alice-desktop-1.onCanvasBdSeven
def onCanvasBdSeven(event)
Definition: alice-desktop-1.3-linux-test.pyw:18166
alice-desktop-1.sel1
def sel1(temp)
Definition: alice-desktop-1.3-linux-test.pyw:5871
alice-desktop-1.BAWGBShape
def BAWGBShape()
Definition: alice-desktop-1.3-linux-test.pyw:11741
alice-desktop-1.BDFiltBMath
def BDFiltBMath()
Definition: alice-desktop-1.3-linux-test.pyw:21612
alice-desktop-1.IBtoggle
def IBtoggle()
Definition: alice-desktop-1.3-linux-test.pyw:15918
alice-desktop-1.CreateToolTip.widget
widget
Definition: alice-desktop-1.3-linux-test.pyw:887
alice-desktop-1.BStartOhm
def BStartOhm()
Definition: alice-desktop-1.3-linux-test.pyw:3087
alice-desktop-1.MakeSampleRateMenu
def MakeSampleRateMenu()
Definition: alice-desktop-1.3-linux-test.pyw:22207
alice-desktop-1.BReadData
def BReadData()
Read scope all time array data from saved file.
Definition: alice-desktop-1.3-linux-test.pyw:2228
alice-desktop-1.AWGBMakeHalfWaveSine
def AWGBMakeHalfWaveSine()
Definition: alice-desktop-1.3.pyw:12650
alice-desktop-1.MakeGenericSerialWindow
def MakeGenericSerialWindow()
Definition: alice-desktop-1.3-linux-test.pyw:21223
alice-desktop-1.onDigFiltAScroll
def onDigFiltAScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:21498
alice-desktop-1.SetScaleMuxD
def SetScaleMuxD()
Definition: alice-desktop-1.3-linux-test.pyw:2945
alice-desktop-1.UpdateAwgCont
def UpdateAwgCont()
Definition: alice-desktop-1.3-linux-test.pyw:12756
alice-desktop-1.onCanvasSASnap
def onCanvasSASnap(event)
Definition: alice-desktop-1.3-linux-test.pyw:17975
alice-desktop-1.BShowCurvesAll
def BShowCurvesAll()
Set to display all time waveforms.
Definition: alice-desktop-1.3-linux-test.pyw:2734
alice-desktop-1.onRetDigFiltB
def onRetDigFiltB(event)
Definition: alice-desktop-1.3-linux-test.pyw:21520
alice-desktop-1.DigPotShiftOut
def DigPotShiftOut(DValue)
Definition: alice-desktop-1.3-linux-test.pyw:20919
alice-desktop-1.MakeNqPScreen
def MakeNqPScreen()
Draw the Nyquist plot screen.
Definition: alice-desktop-1.3-linux-test.pyw:15595
alice-desktop-1.PhACheckBox
def PhACheckBox()
Definition: alice-desktop-1.3-linux-test.pyw:3378
alice-desktop-1.SetXYVBPoss
def SetXYVBPoss()
Definition: alice-desktop-1.3-linux-test.pyw:2987
alice-desktop-1.SchroederPhase
def SchroederPhase(Length, NrTones, Ampl)
Definition: alice-desktop-1.3-linux-test.pyw:10063
alice-desktop-1.Blevel3BP
def Blevel3BP()
Definition: alice-desktop-1.3-linux-test.pyw:13377
alice-desktop-1.BSnapShot
def BSnapShot()
Take snap shot of displayed time waveforms.
Definition: alice-desktop-1.3-linux-test.pyw:2287
alice-desktop-1.AWGAMakeRamp
def AWGAMakeRamp()
Definition: alice-desktop-1.3-linux-test.pyw:11059
alice-desktop-1.DestroyDacScreen
def DestroyDacScreen()
Destroy the DAC Screen.
Definition: alice-desktop-1.3-linux-test.pyw:5832
alice-desktop-1.fit_exp
def fit_exp(xs, ys)
Definition: alice-desktop-1.3-linux-test.pyw:21792
alice-desktop-1.onCanvasBdOne
def onCanvasBdOne(event)
Definition: alice-desktop-1.3-linux-test.pyw:18124
alice-desktop-1.UnWrap
def UnWrap(InArray, WrFactor)
Definition: alice-desktop-1.3-linux-test.pyw:10090
alice-desktop-1.CreateToolTip.waittime
waittime
Definition: alice-desktop-1.3-linux-test.pyw:885
alice-desktop-1.BSaveIASweep
def BSaveIASweep()
Definition: alice-desktop-1.3-linux-test.pyw:15534
alice-desktop-1.BSendDA1
def BSendDA1()
Definition: alice-desktop-1.3-linux-test.pyw:20818
alice-desktop-1.SetColorTR7
def SetColorTR7()
Definition: alice-desktop-1.3.pyw:2379
alice-desktop-1.SyncImage
def SyncImage()
Definition: alice-desktop-1.3-linux-test.pyw:18999
alice-desktop-1.AWGAMakeMath
def AWGAMakeMath()
Definition: alice-desktop-1.3-linux-test.pyw:10481
alice-desktop-1.BTrigger50p
def BTrigger50p()
Set Trigger level to 50% (mid) point of current waveform.
Definition: alice-desktop-1.3-linux-test.pyw:2760
alice-desktop-1.onCanvasBdEight
def onCanvasBdEight(event)
Definition: alice-desktop-1.3-linux-test.pyw:18173
alice-desktop-1.onCanvasSATwo
def onCanvasSATwo(event)
Definition: alice-desktop-1.3-linux-test.pyw:17921
alice-desktop-1.BTriggerMode
def BTriggerMode()
place holder for future hardware triggering if implemented
Definition: alice-desktop-1.3-linux-test.pyw:2801
alice-desktop-1.BShowCurvesNone
def BShowCurvesNone()
Turn off display of all time waveforms.
Definition: alice-desktop-1.3-linux-test.pyw:2744
alice-desktop-1.ResetAllColors
def ResetAllColors()
Definition: alice-desktop-1.3.pyw:2170
alice-desktop-1.UpdateNiCScreen
def UpdateNiCScreen()
Definition: alice-desktop-1.3-linux-test.pyw:15880
alice-desktop-1.MakeSpectrumWindow
def MakeSpectrumWindow()
Definition: alice-desktop-1.3-linux-test.pyw:19421
alice-desktop-1.BAWGBModeLabel
def BAWGBModeLabel()
Definition: alice-desktop-1.3-linux-test.pyw:12579
alice-desktop-1.MakeDigScreen
def MakeDigScreen()
Make the Digital I/O screen.
Definition: alice-desktop-1.3-linux-test.pyw:5752
alice-desktop-1.SetBCompA
def SetBCompA()
Definition: alice-desktop-1.3-linux-test.pyw:11519
alice-desktop-1.onCanvasBdSnap
def onCanvasBdSnap(event)
Definition: alice-desktop-1.3-linux-test.pyw:18185
alice-desktop-1.onCanvasLeftArrow
def onCanvasLeftArrow(event)
Move Time curcors left 1 or 5.
Definition: alice-desktop-1.3-linux-test.pyw:9242
alice-desktop-1.BSaveConfigSA
def BSaveConfigSA()
Save current configuration from SA window.
Definition: alice-desktop-1.3-linux-test.pyw:1563
alice-desktop-1.UpdateAWGB
def UpdateAWGB()
Definition: alice-desktop-1.3-linux-test.pyw:12602
alice-desktop-1.SetMuxCPoss
def SetMuxCPoss()
Definition: alice-desktop-1.3-linux-test.pyw:2897
alice-desktop-1.SelfCalibration
def SelfCalibration()
Definition: alice-desktop-1.3-linux-test.pyw:20043
alice-desktop-1.MakeNicPlot
def MakeNicPlot()
Definition: alice-desktop-1.3-linux-test.pyw:15679
alice-desktop-1.onCanvasBdTwo
def onCanvasBdTwo(event)
Definition: alice-desktop-1.3-linux-test.pyw:18131
alice-desktop-1.AWGAWriteFile
def AWGAWriteFile()
Definition: alice-desktop-1.3-linux-test.pyw:10475
alice-desktop-1.onRetAWGFiltA
def onRetAWGFiltA(event)
Definition: alice-desktop-1.3-linux-test.pyw:21627
alice-desktop-1.onCanvasShowFcur
def onCanvasShowFcur(event)
Definition: alice-desktop-1.3-linux-test.pyw:17990
alice-desktop-1.BuildBoxCarB
def BuildBoxCarB()
Definition: alice-desktop-1.3-linux-test.pyw:21527
alice-desktop-1.onCanvasBdFive
def onCanvasBdFive(event)
Definition: alice-desktop-1.3-linux-test.pyw:18152
alice-desktop-1.onCanvasFour
def onCanvasFour(event)
Definition: alice-desktop-1.3-linux-test.pyw:9661
alice-desktop-1.AWGBMakeTrapazoid
def AWGBMakeTrapazoid()
Definition: alice-desktop-1.3-linux-test.pyw:12175
alice-desktop-1.CreateToolTip.id
id
Definition: alice-desktop-1.3-linux-test.pyw:892
alice-desktop-1.MakeMeasureScreen
def MakeMeasureScreen()
Definition: alice-desktop-1.3-linux-test.pyw:21959
alice-desktop-1.BResetFreqAvg
def BResetFreqAvg()
Definition: alice-desktop-1.3-linux-test.pyw:12877
alice-desktop-1.BCHBlevel
def BCHBlevel()
Definition: alice-desktop-1.3-linux-test.pyw:3254
alice-desktop-1.onSpinBoxScroll
def onSpinBoxScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:18327
alice-desktop-1.onCanvasSix
def onCanvasSix(event)
Definition: alice-desktop-1.3-linux-test.pyw:9674
alice-desktop-1.Blevel4BP
def Blevel4BP()
Definition: alice-desktop-1.3-linux-test.pyw:13386
alice-desktop-1.BAWGBPhase
def BAWGBPhase(temp)
Definition: alice-desktop-1.3-linux-test.pyw:11704
alice-desktop-1.SetColorTR3
def SetColorTR3()
Definition: alice-desktop-1.3.pyw:2335
alice-desktop-1.BDFiltAMath
def BDFiltAMath()
Definition: alice-desktop-1.3-linux-test.pyw:21574
alice-desktop-1.DestroySampleRate
def DestroySampleRate()
Definition: alice-desktop-1.3-linux-test.pyw:22268
alice-desktop-1.MakePhATrace
def MakePhATrace()
Definition: alice-desktop-1.3-linux-test.pyw:16144
alice-desktop-1.onCanvasShowPdBcur
def onCanvasShowPdBcur(event)
Definition: alice-desktop-1.3-linux-test.pyw:18202
alice-desktop-1.BStartSA
def BStartSA()
Definition: alice-desktop-1.3-linux-test.pyw:13064
alice-desktop-1.BSTOREtraceSA
def BSTOREtraceSA()
Definition: alice-desktop-1.3-linux-test.pyw:12883
alice-desktop-1.BAWGAFreq
def BAWGAFreq(temp)
Definition: alice-desktop-1.3-linux-test.pyw:10221
alice-desktop-1.onCanvasBdNine
def onCanvasBdNine(event)
Definition: alice-desktop-1.3-linux-test.pyw:18177
alice-desktop-1.DestroyMeasureScreen
def DestroyMeasureScreen()
Definition: alice-desktop-1.3-linux-test.pyw:22026
alice-desktop-1.Blevel3
def Blevel3()
Definition: alice-desktop-1.3-linux-test.pyw:13152
alice-desktop-1.Blevel2BP
def Blevel2BP()
Definition: alice-desktop-1.3-linux-test.pyw:13368
alice-desktop-1.BLoadConfigSA
def BLoadConfigSA()
Load confirfuration from SA window button.
Definition: alice-desktop-1.3-linux-test.pyw:1901
alice-desktop-1.onCanvasSAFive
def onCanvasSAFive(event)
Definition: alice-desktop-1.3-linux-test.pyw:17942
alice-desktop-1.BSaveConfig
def BSaveConfig(filename)
Save current configureation to file.
Definition: alice-desktop-1.3-linux-test.pyw:940
alice-desktop-1.MakeBodeTrace
def MakeBodeTrace()
Definition: alice-desktop-1.3-linux-test.pyw:14153
alice-desktop-1.DestroyMinigenScreen
def DestroyMinigenScreen()
Destroy DDS board sacrren.
Definition: alice-desktop-1.3-linux-test.pyw:20767
alice-desktop-1.onCanvasBdSix
def onCanvasBdSix(event)
Definition: alice-desktop-1.3-linux-test.pyw:18159
alice-desktop-1.MakeOhmWindow
def MakeOhmWindow()
if askyesno("Flash Failed", "Failed to update firmware.\n Try again?"): try: session....
Definition: alice-desktop-1.3-linux-test.pyw:22511
alice-desktop-1.onAWGAkey
def onAWGAkey(event)
Definition: alice-desktop-1.3-linux-test.pyw:18258
alice-desktop-1.MakeXYScreen
def MakeXYScreen()
Update the XY screen traces and text.
Definition: alice-desktop-1.3-linux-test.pyw:8272
alice-desktop-1.onCanvasNine
def onCanvasNine(event)
Definition: alice-desktop-1.3-linux-test.pyw:9689
alice-desktop-1.onDigFiltBScroll
def onDigFiltBScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:21523
alice-desktop-1.Analog_In
def Analog_In()
Main Loop.
Definition: alice-desktop-1.3-linux-test.pyw:3415
alice-desktop-1.PhACaresize
def PhACaresize(event)
Definition: alice-desktop-1.3-linux-test.pyw:16121
alice-desktop-1.BStepSync
def BStepSync()
Definition: alice-desktop-1.3-linux-test.pyw:19032
alice-desktop-1.BSaveCal
def BSaveCal()
Save gain, offset and filter variables for external dividers.
Definition: alice-desktop-1.3-linux-test.pyw:2338
alice-desktop-1.AWGBMakeUpDownRamp
def AWGBMakeUpDownRamp()
Definition: alice-desktop-1.3-linux-test.pyw:12372
alice-desktop-1.UpdateBodeTrace
def UpdateBodeTrace()
Definition: alice-desktop-1.3-linux-test.pyw:13438
alice-desktop-1.onCanvasClickLeft
def onCanvasClickLeft(event)
Definition: alice-desktop-1.3-linux-test.pyw:9367
alice-desktop-1.Analog_Time_In
def Analog_Time_In()
Scope time main loop Read the analog data and store the data into the arrays.
Definition: alice-desktop-1.3-linux-test.pyw:3700
alice-desktop-1.UpdateFirmware
def UpdateFirmware()
Definition: alice-desktop-1.3-linux-test.pyw:22470
alice-desktop-1.MakeMinigenWindow
def MakeMinigenWindow()
Make AD983x based DDS generator screen.
Definition: alice-desktop-1.3-linux-test.pyw:20687
alice-desktop-1.ReSetAGO
def ReSetAGO()
Definition: alice-desktop-1.3-linux-test.pyw:23345
alice-desktop-1.UpdateNqPTrace
def UpdateNqPTrace()
Definition: alice-desktop-1.3-linux-test.pyw:15856
alice-desktop-1.SPIShiftOut
def SPIShiftOut(DValue)
========== MiniGen routines ========== SPI shift output routine
Definition: alice-desktop-1.3-linux-test.pyw:20603
alice-desktop-1.IACapReset
def IACapReset()
Definition: alice-desktop-1.3-linux-test.pyw:15547
alice-desktop-1.MakeHistogram
def MakeHistogram()
Make histogram of time signals.
Definition: alice-desktop-1.3-linux-test.pyw:5312
alice-desktop-1.MakeDacScreen
def MakeDacScreen()
Make the DAC interface screen
Definition: alice-desktop-1.3-linux-test.pyw:5970
alice-desktop-1.DigPotSend
def DigPotSend(Temp)
Definition: alice-desktop-1.3-linux-test.pyw:20954
alice-desktop-1.PlotPhAFromFile
def PlotPhAFromFile()
Definition: alice-desktop-1.3-linux-test.pyw:17028
alice-desktop-1.FreqCheckBox
def FreqCheckBox()
Definition: alice-desktop-1.3-linux-test.pyw:3338
alice-desktop-1.CAresize
def CAresize(event)
Definition: alice-desktop-1.3-linux-test.pyw:21916
alice-desktop-1.onCanvasXYRightClick
def onCanvasXYRightClick(event)
Definition: alice-desktop-1.3-linux-test.pyw:9737
alice-desktop-1.CheckMathXString
def CheckMathXString()
Check X Math String for syntac errors.
Definition: alice-desktop-1.3-linux-test.pyw:2657
alice-desktop-1.DA1ShiftOut
def DA1ShiftOut(D1Value, D2Value)
if ETSStatus.get() > 0 and ETSDisp.get() > 0: MGLoad()
Definition: alice-desktop-1.3-linux-test.pyw:20780
alice-desktop-1.SetColorTrig
def SetColorTrig()
Definition: alice-desktop-1.3.pyw:2410
alice-desktop-1.MakeBodeScreen
def MakeBodeScreen()
Definition: alice-desktop-1.3-linux-test.pyw:14398
alice-desktop-1.BLoadAWGFiltB
def BLoadAWGFiltB()
Definition: alice-desktop-1.3-linux-test.pyw:21720
alice-desktop-1.onCanvasSnap
def onCanvasSnap(event)
Definition: alice-desktop-1.3-linux-test.pyw:9709
alice-desktop-1.CreateToolTip.unschedule
def unschedule(self)
Un-schedule Action.
Definition: alice-desktop-1.3-linux-test.pyw:906
alice-desktop-1.sel0
def sel0(temp)
Definition: alice-desktop-1.3-linux-test.pyw:5838
alice-desktop-1.AWGBLoadWAV
def AWGBLoadWAV()
Definition: alice-desktop-1.3-linux-test.pyw:11850
alice-desktop-1.SetIAPoss
def SetIAPoss()
Definition: alice-desktop-1.3-linux-test.pyw:2969
alice-desktop-1.OpenOtherTools
def OpenOtherTools()
Definition: alice-desktop-1.3-linux-test.pyw:23377
alice-desktop-1.AWGBMakeUGNoise
def AWGBMakeUGNoise()
Definition: alice-desktop-1.3-linux-test.pyw:12537
alice-desktop-1.onCanvasBodeClickScroll
def onCanvasBodeClickScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:18023
alice-desktop-1.BSaveMuxData
def BSaveMuxData()
Save External Mux data to file.
Definition: alice-desktop-1.3-linux-test.pyw:2118
alice-desktop-1.onCanvasSASix
def onCanvasSASix(event)
Definition: alice-desktop-1.3-linux-test.pyw:17949
alice-desktop-1.onStopBodeScroll
def onStopBodeScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:22342
alice-desktop-1.IACapZero
def IACapZero()
Definition: alice-desktop-1.3-linux-test.pyw:15540
alice-desktop-1.VAtoggle
def VAtoggle()
Definition: alice-desktop-1.3-linux-test.pyw:15886
alice-desktop-1.AWGBMakeFourier
def AWGBMakeFourier()
Definition: alice-desktop-1.3-linux-test.pyw:11916
alice-desktop-1.AWGAMakeTrapazoid
def AWGAMakeTrapazoid()
Definition: alice-desktop-1.3-linux-test.pyw:10922
alice-desktop-1.Blevel1BP
def Blevel1BP()
Definition: alice-desktop-1.3-linux-test.pyw:13359
alice-desktop-1.ReSetBIGO
def ReSetBIGO()
Definition: alice-desktop-1.3-linux-test.pyw:23369
alice-desktop-1.ETSUpdate
def ETSUpdate()
Definition: alice-desktop-1.3-linux-test.pyw:22738
alice-desktop-1.UpdateFreqTrace
def UpdateFreqTrace()
Definition: alice-desktop-1.3-linux-test.pyw:13458
alice-desktop-1.ReSetBGO
def ReSetBGO()
Definition: alice-desktop-1.3-linux-test.pyw:23353
alice-desktop-1.BlueNoise
def BlueNoise(N, mag)
Definition: alice-desktop-1.3-linux-test.pyw:10015
alice-desktop-1.SetMuxBPoss
def SetMuxBPoss()
Definition: alice-desktop-1.3-linux-test.pyw:2891
alice-desktop-1.shift_buffer
def shift_buffer(arr, num, fill_value=numpy.nan)
Function to left (-num) or right (+num) shift buffer and fill with a value returns same length buffer...
Definition: alice-desktop-1.3-linux-test.pyw:5000
alice-desktop-1.UpdatePhAAll
def UpdatePhAAll()
Definition: alice-desktop-1.3-linux-test.pyw:16130
alice-desktop-1.onCanvasBdThree
def onCanvasBdThree(event)
Definition: alice-desktop-1.3-linux-test.pyw:18138
alice-desktop-1.NqPCaresize
def NqPCaresize(event)
Definition: alice-desktop-1.3-linux-test.pyw:15585
alice-desktop-1.BDBdiv2
def BDBdiv2()
Definition: alice-desktop-1.3-linux-test.pyw:13222
alice-desktop-1.Save_Cal_file
def Save_Cal_file()
Definition: alice-desktop-1.3-linux-test.pyw:20510
alice-desktop-1.MakeAWGWindow
def MakeAWGWindow()
Definition: alice-desktop-1.3-linux-test.pyw:18337
alice-desktop-1.SplitAWGAwaveform
def SplitAWGAwaveform()
Definition: alice-desktop-1.3-linux-test.pyw:10394
alice-desktop-1.BAWGBFreq
def BAWGBFreq(temp)
Definition: alice-desktop-1.3-linux-test.pyw:11647
alice-desktop-1.onCanvasBdFour
def onCanvasBdFour(event)
Definition: alice-desktop-1.3-linux-test.pyw:18145
alice-desktop-1.UpdateTimeAll
def UpdateTimeAll()
Update Data, trace and time screen.
Definition: alice-desktop-1.3-linux-test.pyw:5992
alice-desktop-1.NiCCaresize
def NiCCaresize(event)
Definition: alice-desktop-1.3-linux-test.pyw:15712
alice-desktop-1.CreateToolTip.configure
def configure(self, text)
Re Configure text string.
Definition: alice-desktop-1.3-linux-test.pyw:934
alice-desktop-1.CreateToolTip.enter
def enter(self, event=None)
Action when mouse enters.
Definition: alice-desktop-1.3-linux-test.pyw:895
alice-desktop-1.Analog_Phase_In
def Analog_Phase_In()
Definition: alice-desktop-1.3-linux-test.pyw:3769
alice-desktop-1.BAWGBOffset
def BAWGBOffset(temp)
Definition: alice-desktop-1.3-linux-test.pyw:11609
alice-desktop-1.BHoldOff
def BHoldOff(event)
Set Hold off time from entry widget.
Definition: alice-desktop-1.3-linux-test.pyw:2827
alice-desktop-1.BHistAsPercent
def BHistAsPercent()
Plot Histogram as Percent?
Definition: alice-desktop-1.3-linux-test.pyw:5353
alice-desktop-1.SetSampleRate
def SetSampleRate()
Definition: alice-desktop-1.3-linux-test.pyw:22285
alice-desktop-1.onCanvasSAEight
def onCanvasSAEight(event)
Definition: alice-desktop-1.3-linux-test.pyw:17963
alice-desktop-1.UpdateFreqScreen
def UpdateFreqScreen()
Definition: alice-desktop-1.3-linux-test.pyw:13462
alice-desktop-1.AWGAMakeHalfWaveSine
def AWGAMakeHalfWaveSine()
Definition: alice-desktop-1.3.pyw:11223
alice-desktop-1.DoFFT
def DoFFT()
Definition: alice-desktop-1.3-linux-test.pyw:13465
alice-desktop-1.onCanvasClickScroll
def onCanvasClickScroll(event)
Shift Time or vertical cursors if on or shift gated measurement cursors if enabled.
Definition: alice-desktop-1.3-linux-test.pyw:9113
alice-desktop-1.CreateToolTip.__init__
def __init__(self, widget, text='widget info')
create a tooltip for a given widget
Definition: alice-desktop-1.3-linux-test.pyw:884
alice-desktop-1.BAWGSync
def BAWGSync()
Definition: alice-desktop-1.3-linux-test.pyw:12790
alice-desktop-1.sel3
def sel3(temp)
Definition: alice-desktop-1.3-linux-test.pyw:5937
alice-desktop-1.IACheckBox
def IACheckBox()
Definition: alice-desktop-1.3-linux-test.pyw:3365
alice-desktop-1.SetMuxAPoss
def SetMuxAPoss()
Analog Mux buttons.
Definition: alice-desktop-1.3-linux-test.pyw:2885
alice-desktop-1.IACaresize
def IACaresize(event)
Definition: alice-desktop-1.3-linux-test.pyw:15320
alice-desktop-1.Wrap
def Wrap(InArray, WrFactor)
Definition: alice-desktop-1.3-linux-test.pyw:10076
alice-desktop-1.SetScaleMuxA
def SetScaleMuxA()
Definition: alice-desktop-1.3-linux-test.pyw:2909
alice-desktop-1.MakeBodeWindow
def MakeBodeWindow()
Definition: alice-desktop-1.3-linux-test.pyw:19097
alice-desktop-1.BSaveChannelData
def BSaveChannelData()
Save selected scope time array data to file.
Definition: alice-desktop-1.3-linux-test.pyw:2132
alice-desktop-1.BShowCurvesAllBP
def BShowCurvesAllBP()
Definition: alice-desktop-1.3-linux-test.pyw:13416
alice-desktop-1.DestroyAD5626Screen
def DestroyAD5626Screen()
Definition: alice-desktop-1.3-linux-test.pyw:21217
alice-desktop-1.SetColorT4
def SetColorT4()
Definition: alice-desktop-1.3.pyw:2259
alice-desktop-1.DestroyBodeScreen
def DestroyBodeScreen()
Definition: alice-desktop-1.3-linux-test.pyw:19401
alice-desktop-1.TimeSeriesSingleTone
def TimeSeriesSingleTone(n, BinNum, Fsample, mag)
Definition: alice-desktop-1.3-linux-test.pyw:9989
alice-desktop-1.BAWGAAmpl
def BAWGAAmpl(temp)
Definition: alice-desktop-1.3-linux-test.pyw:10143
alice-desktop-1.UpdateXYAll
def UpdateXYAll()
Update Data, trace and XY screen.
Definition: alice-desktop-1.3-linux-test.pyw:6007
alice-desktop-1.BAveragemode
def BAveragemode()
Definition: alice-desktop-1.3-linux-test.pyw:12867
alice-desktop-1.SettingsUpdate
def SettingsUpdate()
Definition: alice-desktop-1.3-linux-test.pyw:23140
alice-desktop-1.UpdateIATrace
def UpdateIATrace()
Definition: alice-desktop-1.3-linux-test.pyw:14734
alice-desktop-1.DestroyAWGScreen
def DestroyAWGScreen()
Definition: alice-desktop-1.3-linux-test.pyw:18737
alice-desktop-1.CreateToolTip.text
text
Definition: alice-desktop-1.3-linux-test.pyw:888
alice-desktop-1.XYcaresize
def XYcaresize(event)
Definition: alice-desktop-1.3-linux-test.pyw:19742
alice-desktop-1.UpdateNiCTrace
def UpdateNiCTrace()
Definition: alice-desktop-1.3-linux-test.pyw:15875
alice-desktop-1.BAWGAPhaseDelay
def BAWGAPhaseDelay()
Definition: alice-desktop-1.3-linux-test.pyw:10268
alice-desktop-1.MGLoad
def MGLoad()
Definition: alice-desktop-1.3-linux-test.pyw:22696
alice-desktop-1.BLoadAWGBFiltClip
def BLoadAWGBFiltClip()
Definition: alice-desktop-1.3-linux-test.pyw:2221
alice-desktop-1.BPeakholdmode
def BPeakholdmode()
Definition: alice-desktop-1.3-linux-test.pyw:12857
color-chooser-test.askcolor
def askcolor(text)
Definition: color-chooser-test.py:31
alice-desktop-1.PinkNoise
def PinkNoise(N, mag)
Definition: alice-desktop-1.3-linux-test.pyw:10000
alice-desktop-1.DestroyDigFiltScreen
def DestroyDigFiltScreen()
Definition: alice-desktop-1.3-linux-test.pyw:21545
alice-desktop-1.onCanvasOne
def onCanvasOne(event)
Definition: alice-desktop-1.3-linux-test.pyw:9637
alice-desktop-1.Blevel1
def Blevel1()
Definition: alice-desktop-1.3-linux-test.pyw:13134
alice-desktop-1.MakeTimeTrace
def MakeTimeTrace()
Make the scope time traces.
Definition: alice-desktop-1.3-linux-test.pyw:6022
alice-desktop-1.CreateToolTip.wraplength
wraplength
Definition: alice-desktop-1.3-linux-test.pyw:886
alice-desktop-1.AWGAMakeImpulse
def AWGAMakeImpulse()
Definition: alice-desktop-1.3-linux-test.pyw:11190
alice-desktop-1.BRoll
def BRoll()
Toggel on/off Roll Sweep Mode.
Definition: alice-desktop-1.3-linux-test.pyw:3188
alice-desktop-1.SplitAWGBwaveform
def SplitAWGBwaveform()
Definition: alice-desktop-1.3-linux-test.pyw:11821
alice-desktop-1.SetXYIBPoss
def SetXYIBPoss()
Definition: alice-desktop-1.3-linux-test.pyw:2999
messagebox
alice-desktop-1.SetColorT6
def SetColorT6()
Definition: alice-desktop-1.3.pyw:2285
alice-desktop-1.Blevel2
def Blevel2()
Definition: alice-desktop-1.3-linux-test.pyw:13143
alice-desktop-1.OhmCheckBox
def OhmCheckBox()
Definition: alice-desktop-1.3-linux-test.pyw:3391
alice-desktop-1.onAD5626Scroll
def onAD5626Scroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:21213
alice-desktop-1.Analog_Freq_In
def Analog_Freq_In()
Main SA and Bode loop Read from the stream and store the data into the arrays.
Definition: alice-desktop-1.3-linux-test.pyw:5014
alice-desktop-1.MakeDigFiltWindow
def MakeDigFiltWindow()
Make screen for applying digital filters.
Definition: alice-desktop-1.3-linux-test.pyw:21322
alice-desktop-1.AWGBMakeSinc
def AWGBMakeSinc()
Definition: alice-desktop-1.3-linux-test.pyw:12061
alice-desktop-1.SetChopMuxMode
def SetChopMuxMode()
Definition: alice-desktop-1.3-linux-test.pyw:18970
alice-desktop-1.BLoadDFiltA
def BLoadDFiltA()
Definition: alice-desktop-1.3-linux-test.pyw:21551
alice-desktop-1.FindTriggerSample
def FindTriggerSample(TrgBuff)
Find the sample where trigger event happened.
Definition: alice-desktop-1.3-linux-test.pyw:5523
alice-desktop-1.onCanvasDownArrow
def onCanvasDownArrow(event)
Move Vertical cursors down 1 or 5.
Definition: alice-desktop-1.3-linux-test.pyw:9200
alice-desktop-1.CreateToolTip.leave
def leave(self, event=None)
Action when mouse leaves.
Definition: alice-desktop-1.3-linux-test.pyw:898
alice-desktop-1.TimeSeriesNoise
def TimeSeriesNoise(n, Fsample, mag, b=4)
Definition: alice-desktop-1.3-linux-test.pyw:9967
alice-desktop-1.onCanvasSpaceBar
def onCanvasSpaceBar(event)
Pause / start on space bar.
Definition: alice-desktop-1.3-linux-test.pyw:9326
alice-desktop-1.MakeNyquistPlot
def MakeNyquistPlot()
Definition: alice-desktop-1.3-linux-test.pyw:15553
alice-desktop-1.onRetDigFiltA
def onRetDigFiltA(event)
Definition: alice-desktop-1.3-linux-test.pyw:21495
alice-desktop-1.SetScaleIA
def SetScaleIA()
Definition: alice-desktop-1.3-linux-test.pyw:9054
alice-desktop-1.FindRisingEdge
def FindRisingEdge(Trace1, Trace2)
Routine to find rising edge of traces.
Definition: alice-desktop-1.3-linux-test.pyw:5361
alice-desktop-1.MakeBoardScreen
def MakeBoardScreen()
Definition: alice-desktop-1.3-linux-test.pyw:22032
alice-desktop-1.AWGAMakeAMSine
def AWGAMakeAMSine()
Definition: alice-desktop-1.3-linux-test.pyw:10653
alice-desktop-1.AWGAMakePWMSine
def AWGAMakePWMSine()
Definition: alice-desktop-1.3-linux-test.pyw:10727
alice-desktop-1.SetAD9833
def SetAD9833(temp)
Definition: alice-desktop-1.3-linux-test.pyw:20625
alice-desktop-1.DestroyMuxScreen
def DestroyMuxScreen()
Definition: alice-desktop-1.3-linux-test.pyw:19007
alice-desktop-1.onCanvasShowdBcur
def onCanvasShowdBcur(event)
Definition: alice-desktop-1.3-linux-test.pyw:17997
alice-desktop-1.BuildAWGBoxCarA
def BuildAWGBoxCarA()
Definition: alice-desktop-1.3-linux-test.pyw:21634
alice-desktop-1.AWGBNumCycles
def AWGBNumCycles()
Definition: alice-desktop-1.3-linux-test.pyw:11556
alice-desktop-1.SetXYIAPoss
def SetXYIAPoss()
Definition: alice-desktop-1.3-linux-test.pyw:2993
alice-desktop-1.BSendGS
def BSendGS()
Definition: alice-desktop-1.3-linux-test.pyw:21069
alice-desktop-1.onTextKey
def onTextKey(event)
Definition: alice-desktop-1.3-linux-test.pyw:18275
alice-desktop-1.SetColorTR6
def SetColorTR6()
Definition: alice-desktop-1.3.pyw:2368
alice-desktop-1.Bnot
def Bnot()
Definition: alice-desktop-1.3-linux-test.pyw:12830
alice-desktop-1.BSetMarkerLocation
def BSetMarkerLocation()
Ask user for new Marker text location on screen.
Definition: alice-desktop-1.3-linux-test.pyw:2718
alice-desktop-1.MakePhAWindow
def MakePhAWindow()
Definition: alice-desktop-1.3-linux-test.pyw:15927
alice-desktop-1.onCanvasTrising
def onCanvasTrising(event)
Definition: alice-desktop-1.3-linux-test.pyw:9699
alice-desktop-1.BLoadConfigBP
def BLoadConfigBP()
Load confirfuration from Bode window button.
Definition: alice-desktop-1.3-linux-test.pyw:1907
alice-desktop-1.AWGBLoadCSV
def AWGBLoadCSV()
Definition: alice-desktop-1.3-linux-test.pyw:11783
alice-desktop-1.onAWGBscroll
def onAWGBscroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:18217
alice-desktop-1.TraceSelectADC_Mux
def TraceSelectADC_Mux()
Definition: alice-desktop-1.3-linux-test.pyw:22430
alice-desktop-1.SetColorT3
def SetColorT3()
Definition: alice-desktop-1.3.pyw:2244
alice-desktop-1.onCanvasTfalling
def onCanvasTfalling(event)
Definition: alice-desktop-1.3-linux-test.pyw:9704
alice-desktop-1.CALCFFTwindowshape
def CALCFFTwindowshape()
Definition: alice-desktop-1.3-linux-test.pyw:17652
alice-desktop-1.ETSCheckBox
def ETSCheckBox()
Definition: alice-desktop-1.3-linux-test.pyw:3404
alice-desktop-1.SetColorText
def SetColorText()
Definition: alice-desktop-1.3.pyw:2400
alice-desktop-1.onAWGFiltAScroll
def onAWGFiltAScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:21630
alice-desktop-1.AWGAMakeUGNoise
def AWGAMakeUGNoise()
Definition: alice-desktop-1.3-linux-test.pyw:11291
alice-desktop-1.MakeIAScreen
def MakeIAScreen()
Draw the impedance Analyzer screen.
Definition: alice-desktop-1.3-linux-test.pyw:14913
alice-desktop-1.onTextScroll
def onTextScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:18225
alice-desktop-1.AWGAMakeFourier
def AWGAMakeFourier()
Definition: alice-desktop-1.3-linux-test.pyw:10768
alice-desktop-1.AWGAReadFile
def AWGAReadFile()
Definition: alice-desktop-1.3-linux-test.pyw:10346
alice-desktop-1.BSaveScreenXY
def BSaveScreenXY()
Save XY canvas as encapsulated postscript file.
Definition: alice-desktop-1.3-linux-test.pyw:2052
alice-desktop-1.UpdateBodeScreen
def UpdateBodeScreen()
Definition: alice-desktop-1.3-linux-test.pyw:13442
alice-desktop-1.BAWGADutyCycle
def BAWGADutyCycle(temp)
Definition: alice-desktop-1.3-linux-test.pyw:10296
alice-desktop-1.MakeCommandScreen
def MakeCommandScreen()
Definition: alice-desktop-1.3-linux-test.pyw:21809
alice-desktop-1.BSaveToClipBoard
def BSaveToClipBoard(TempBuffer)
Definition: alice-desktop-1.3-linux-test.pyw:2184
alice-desktop-1.BAbout
def BAbout()
Show info on software / firmware / hardware.
Definition: alice-desktop-1.3-linux-test.pyw:2267
alice-desktop-1.DestroyDigScreen
def DestroyDigScreen()
Distroy the Digital I/O screen.
Definition: alice-desktop-1.3-linux-test.pyw:5642
alice-desktop-1.BCHBIlevel
def BCHBIlevel()
Definition: alice-desktop-1.3-linux-test.pyw:3265
alice-desktop-1.BUserFFTwindow
def BUserFFTwindow()
Definition: alice-desktop-1.3-linux-test.pyw:17741
alice-desktop-1.Write_WAV
def Write_WAV(data, repeat, filename)
Definition: alice-desktop-1.3-linux-test.pyw:10107
alice-desktop-1.SetScaleMuxC
def SetScaleMuxC()
Definition: alice-desktop-1.3-linux-test.pyw:2933
alice-desktop-1.SetMuxDPoss
def SetMuxDPoss()
Definition: alice-desktop-1.3-linux-test.pyw:2903
alice-desktop-1.BSaveScreen
def BSaveScreen()
Save scope canvas as encapsulated postscript file.
Definition: alice-desktop-1.3-linux-test.pyw:2033
alice-desktop-1.TimeCheckBox
def TimeCheckBox()
set check box colors
Definition: alice-desktop-1.3-linux-test.pyw:3324
alice-desktop-1.BPower
def BPower()
Toggel on/off analog power.
Definition: alice-desktop-1.3-linux-test.pyw:3174
alice-desktop-1.CreateToolTip.showtip
def showtip(self, event=None)
Display Tip Text.
Definition: alice-desktop-1.3-linux-test.pyw:912
alice-desktop-1.BDBdiv1BP
def BDBdiv1BP()
Definition: alice-desktop-1.3-linux-test.pyw:13395
alice-desktop-1.BodeCheckBox
def BodeCheckBox()
Definition: alice-desktop-1.3-linux-test.pyw:3351
alice-desktop-1.MakeXYWindow
def MakeXYWindow()
Definition: alice-desktop-1.3-linux-test.pyw:19758
alice-desktop-1.AWGBConfigMath
def AWGBConfigMath()
Definition: alice-desktop-1.3-linux-test.pyw:11904
alice-desktop-1.BLoadConfigIA
def BLoadConfigIA()
Load confirfuration from IA window button.
Definition: alice-desktop-1.3-linux-test.pyw:1895
alice-desktop-1.BUserCustomPlotText
def BUserCustomPlotText()
Ask user to enter custom plot label string.
Definition: alice-desktop-1.3-linux-test.pyw:2464
alice-desktop-1.ReSetAIGO
def ReSetAIGO()
Definition: alice-desktop-1.3-linux-test.pyw:23361
alice-desktop-1.SetColorT1
def SetColorT1()
Definition: alice-desktop-1.3.pyw:2214
alice-desktop-1.BSaveScreenSA
def BSaveScreenSA()
Definition: alice-desktop-1.3-linux-test.pyw:12813
alice-desktop-1.AWGAMakeFullWaveSine
def AWGAMakeFullWaveSine()
Definition: alice-desktop-1.3.pyw:11161
alice-desktop-1.BShowCurvesAllSA
def BShowCurvesAllSA()
Definition: alice-desktop-1.3-linux-test.pyw:12833
alice-desktop-1.donothing
def donothing()
Nop.
Definition: alice-desktop-1.3-linux-test.pyw:2728
alice-desktop-1.SettingsTextKey
def SettingsTextKey(event)
Definition: alice-desktop-1.3-linux-test.pyw:22826
alice-desktop-1.BuildAWGBoxCarB
def BuildAWGBoxCarB()
Definition: alice-desktop-1.3-linux-test.pyw:21660
alice-desktop-1.onCanvasShowVcur
def onCanvasShowVcur(event)
Definition: alice-desktop-1.3-linux-test.pyw:9729
alice-desktop-1.VioletNoise
def VioletNoise(N, mag)
Definition: alice-desktop-1.3-linux-test.pyw:10047
alice-desktop-1.CheckMathYString
def CheckMathYString()
Check Y Math String for syntac errors.
Definition: alice-desktop-1.3-linux-test.pyw:2677
alice-desktop-1.onCanvasSASeven
def onCanvasSASeven(event)
Definition: alice-desktop-1.3-linux-test.pyw:17956
alice-desktop-1.MakeTimeScreen
def MakeTimeScreen()
Update the time screen with traces and text
Definition: alice-desktop-1.3-linux-test.pyw:7377
alice-desktop-1.BStopBP
def BStopBP()
Definition: alice-desktop-1.3-linux-test.pyw:13337
alice-desktop-1.Settingsscroll
def Settingsscroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:22822
alice-desktop-1.onCanvasSAReset
def onCanvasSAReset(event)
Definition: alice-desktop-1.3-linux-test.pyw:17984
alice-desktop-1.BSaveDataIA
def BSaveDataIA()
Definition: alice-desktop-1.3-linux-test.pyw:13037
alice-desktop-1.UpdateXYTrace
def UpdateXYTrace()
Update XY trace and screen.
Definition: alice-desktop-1.3-linux-test.pyw:6012
alice-desktop-1.BDBdiv2BP
def BDBdiv2BP()
Definition: alice-desktop-1.3-linux-test.pyw:13405
alice-desktop-1.BShowCurvesNoneBP
def BShowCurvesNoneBP()
Definition: alice-desktop-1.3-linux-test.pyw:13423
alice-desktop-1.BStart
def BStart()
Start aquaring scope time data.
Definition: alice-desktop-1.3-linux-test.pyw:3031
alice-desktop-1.SetVAPoss
def SetVAPoss()
Definition: alice-desktop-1.3-linux-test.pyw:2957
alice-desktop-1.sel2
def sel2(temp)
Definition: alice-desktop-1.3-linux-test.pyw:5904
alice-desktop-1.ResetColors
def ResetColors()
Colors that can be modified Use function to reset to "factory" colors.
Definition: alice-desktop-1.3.pyw:137
alice-desktop-1.DestroySettings
def DestroySettings()
Definition: alice-desktop-1.3-linux-test.pyw:23324
alice-desktop-1.BodeCaresize
def BodeCaresize(event)
Definition: alice-desktop-1.3-linux-test.pyw:19023
alice-desktop-1.SetColorGrid
def SetColorGrid()
Definition: alice-desktop-1.3.pyw:2390
alice-desktop-1.onAWGAscroll
def onAWGAscroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:18209
alice-desktop-1.BuildRejectFilter
def BuildRejectFilter(Order, Freject, Fsample)
Definition: alice-desktop-1.3-linux-test.pyw:21761
alice-desktop-1.AWGAConfigMath
def AWGAConfigMath()
Definition: alice-desktop-1.3-linux-test.pyw:10503
alice-desktop-1.FreqCaresize
def FreqCaresize(event)
Definition: alice-desktop-1.3-linux-test.pyw:19411
alice-desktop-1.Ohm_Analog_In
def Ohm_Analog_In()
Ohmmeter loop.
Definition: alice-desktop-1.3-linux-test.pyw:3578
ttk
alice-desktop-1.AWGBMakeBodeSine
def AWGBMakeBodeSine()
Definition: alice-desktop-1.3-linux-test.pyw:11951
alice-desktop-1.BHozPoss
def BHozPoss(event)
Definition: alice-desktop-1.3-linux-test.pyw:2838
alice-desktop-1.BSetFmin
def BSetFmin()
Definition: alice-desktop-1.3-linux-test.pyw:23337
alice-desktop-1.CreateToolTip
Tool Tip Ballon help stuff.
Definition: alice-desktop-1.3-linux-test.pyw:882
alice-desktop-1.MakeDigPotWindow
def MakeDigPotWindow()
set up controls for single, dual or quad, digital pots
Definition: alice-desktop-1.3-linux-test.pyw:21012
alice-desktop-1.Bsamples1
def Bsamples1()
Definition: alice-desktop-1.3-linux-test.pyw:13170
alice-desktop-1.BLoadCal
def BLoadCal()
Load gain, offset and filter variables for external dividers.
Definition: alice-desktop-1.3-linux-test.pyw:2410
alice-desktop-1.Cal_trace_scalars
def Cal_trace_scalars(SampleStart, SampleEnd)
Definition: alice-desktop-1.3-linux-test.pyw:4909
alice-desktop-1.SetXYScaleB
def SetXYScaleB()
Definition: alice-desktop-1.3-linux-test.pyw:9097
alice-desktop-1.VABtoggle
def VABtoggle()
Definition: alice-desktop-1.3-linux-test.pyw:15894
alice-desktop-1.BAWGAShape
def BAWGAShape()
Definition: alice-desktop-1.3-linux-test.pyw:10315
alice-desktop-1.ConnectDevice
def ConnectDevice()
Definition: alice-desktop-1.3-linux-test.pyw:22087
alice-desktop-1.DestroyGenericSerialScreen
def DestroyGenericSerialScreen()
Definition: alice-desktop-1.3-linux-test.pyw:21315
alice-desktop-1.BLoadAWGAFiltClip
def BLoadAWGAFiltClip()
Definition: alice-desktop-1.3-linux-test.pyw:2215
alice-desktop-1.BAWGEnab
def BAWGEnab()
Definition: alice-desktop-1.3-linux-test.pyw:12769
alice-desktop-1.MakeDA1Window
def MakeDA1Window()
Make window to control PMOD DA1 board.
Definition: alice-desktop-1.3-linux-test.pyw:20862
alice-desktop-1.CreateToolTip.schedule
def schedule(self)
Sehedule Action.
Definition: alice-desktop-1.3-linux-test.pyw:902
alice-desktop-1.onTextKeyAWG
def onTextKeyAWG(event)
Definition: alice-desktop-1.3-linux-test.pyw:18270
alice-desktop-1.BStartBP
def BStartBP()
Definition: alice-desktop-1.3-linux-test.pyw:13233
alice-desktop-1.onStopfreqScroll
def onStopfreqScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:22322
alice-desktop-1.BCSVfile
def BCSVfile()
Definition: alice-desktop-1.3-linux-test.pyw:12963
alice-desktop-1.SetScaleA
def SetScaleA()
Definition: alice-desktop-1.3-linux-test.pyw:9042
alice-desktop-1.BSaveScreenIA
def BSaveScreenIA()
Save IA canvas as encapsulated postscript file.
Definition: alice-desktop-1.3-linux-test.pyw:2071
alice-desktop-1.onCanvasSAFour
def onCanvasSAFour(event)
Definition: alice-desktop-1.3-linux-test.pyw:17935
alice-desktop-1.MakeSettingsMenu
def MakeSettingsMenu()
Definition: alice-desktop-1.3-linux-test.pyw:22830
alice-desktop-1.BUserAMeas
def BUserAMeas()
Ask user for channel A Measurement Label and Formula.
Definition: alice-desktop-1.3-linux-test.pyw:2429
alice-desktop-1.UpdateXYScreen
def UpdateXYScreen()
Update XY screen with trace and text.
Definition: alice-desktop-1.3-linux-test.pyw:6017
alice-desktop-1.onCanvasBodeRightClick
def onCanvasBodeRightClick(event)
Definition: alice-desktop-1.3-linux-test.pyw:18011
alice-desktop-1.BSendMG
def BSendMG()
Send serial data to DDS board.
Definition: alice-desktop-1.3-linux-test.pyw:20655
alice-desktop-1.onCanvasUpArrow
def onCanvasUpArrow(event)
Move Vertical cursors up 1 or 5.
Definition: alice-desktop-1.3-linux-test.pyw:9158
alice-desktop-1.AWGBWriteFile
def AWGBWriteFile()
Definition: alice-desktop-1.3-linux-test.pyw:11876
alice-desktop-1.BSavePhAData
def BSavePhAData()
Definition: alice-desktop-1.3-linux-test.pyw:16992
alice-desktop-1.UpdateBodeAll
def UpdateBodeAll()
Definition: alice-desktop-1.3-linux-test.pyw:13430
alice-desktop-1.BUserBMeas
def BUserBMeas()
Ask user for channel B Measurement Label and Formula.
Definition: alice-desktop-1.3-linux-test.pyw:2446
alice-desktop-1.Blevel4
def Blevel4()
Definition: alice-desktop-1.3-linux-test.pyw:13161
alice-desktop-1.BOffsetA
def BOffsetA(event)
Definition: alice-desktop-1.3-linux-test.pyw:3276
alice-desktop-1.DestroyNiCScreen
def DestroyNiCScreen()
Definition: alice-desktop-1.3-linux-test.pyw:15705
alice-desktop-1.BTime
def BTime()
Set Hor time scale from entry widget.
Definition: alice-desktop-1.3-linux-test.pyw:3199
alice-desktop-1.onCanvasSAAverage
def onCanvasSAAverage(event)
Definition: alice-desktop-1.3-linux-test.pyw:17987
alice-desktop-1.AWGAMakeBodeSine
def AWGAMakeBodeSine()
Definition: alice-desktop-1.3-linux-test.pyw:10515
alice-desktop-1.DestroyColorScreen
def DestroyColorScreen()
Definition: alice-desktop-1.3.pyw:2163
alice-desktop-1.onCanvasSANormal
def onCanvasSANormal(event)
Definition: alice-desktop-1.3-linux-test.pyw:17978
alice-desktop-1.BCHAIlevel
def BCHAIlevel()
Definition: alice-desktop-1.3-linux-test.pyw:3243
alice-desktop-1.onCanvasFreqClickScroll
def onCanvasFreqClickScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:17783
alice-desktop-1.CreateToolTip.hidetip
def hidetip(self)
Hide Tip Action.
Definition: alice-desktop-1.3-linux-test.pyw:928
alice-desktop-1.BStop
def BStop()
Stop (pause) scope tool.
Definition: alice-desktop-1.3-linux-test.pyw:3141
alice-desktop-1.DestroyDA1Screen
def DestroyDA1Screen()
Destroy PMOD DA1 screen.
Definition: alice-desktop-1.3-linux-test.pyw:20913
alice-desktop-1.onCanvasEight
def onCanvasEight(event)
Definition: alice-desktop-1.3-linux-test.pyw:9684
alice-desktop-1.onCanvasFreqRightClick
def onCanvasFreqRightClick(event)
Definition: alice-desktop-1.3-linux-test.pyw:17772
alice-desktop-1.onCanvasSAOne
def onCanvasSAOne(event)
Definition: alice-desktop-1.3-linux-test.pyw:17914
alice-desktop-1.SetColorZLine
def SetColorZLine()
Definition: alice-desktop-1.3.pyw:2421
alice-desktop-1.BAWGBAmpl
def BAWGBAmpl(temp)
Definition: alice-desktop-1.3-linux-test.pyw:11570
alice-desktop-1.BAWGFiltAMath
def BAWGFiltAMath()
Definition: alice-desktop-1.3-linux-test.pyw:21703
alice-desktop-1.SetScaleIB
def SetScaleIB()
Definition: alice-desktop-1.3-linux-test.pyw:9078
alice-desktop-1.AWGAMakeUpDownRamp
def AWGAMakeUpDownRamp()
Definition: alice-desktop-1.3-linux-test.pyw:11122
alice-desktop-1.BgColor
def BgColor()
Toggle the Background and text colors based on ColorMode.
Definition: alice-desktop-1.3-linux-test.pyw:1998
alice-desktop-1.onFminScroll
def onFminScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:22710